private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { Console.CursorVisible = true; if (_pendingExit) { return; //already trying to exit - allow normal behaviour on subsequent presses } _pendingExit = true; _analyser.Cancel(); e.Cancel = true; }