/// <summary>
        /// Closes a given transfer, and frees resources that were associated with the
        /// transfer (by invoking the <see cref="FinalizeTransfer"/> method).
        /// </summary>
        /// <returns>The suggested <param name="status" /> if the transfer was found, or
        /// <see cref="TransferStatus.UnknownTransfer"/> if no matching transfer was found.</returns>
        protected virtual TransferStatus CloseTransferInternal(string transferId, TransferStatus status, AbortReason?abortReason, FileSystemTask context, AuditEvent eventId)
        {
            //try to get the transfer
            TTransfer transfer = GetCachedTransfer(transferId, false, context);

            //if we don't have this one (anymore), return corresponding flag
            if (transfer == null)
            {
                return(TransferStatus.UnknownTransfer);
            }

            lock (transfer.SyncRoot)
            {
                CloseTransferImpl(transfer, status, abortReason);

                transfer.Status      = status;
                transfer.AbortReason = abortReason;

                FinalizeTransfer(transfer);
            }

            //audit status change
            Auditor.AuditChangedTransferStatus(transfer, context, eventId);

            return(status);
        }