// cleans up public void Close(CancelEventArgs e) { // set global exit exit = true; // if there was an active file transfer if (fileTransfer.CancelTransfer()) { // cancel closing of the GUI e.Cancel = true; } else { // delete local temp folder DeleteLocalDirectory(localPath); } }