private void HandleCancelKeyPress(object sender, ConsoleCancelEventArgs e) { Copier copier = _copier; if (copier == null) { return; } lock (_consoleInteraction) { Console.WriteLine("Are you sure you want to stop process? Press Y to stop safely"); Console.Write("Press X to stop immediately, any other key to continue..."); var key = char.ToUpper(Console.ReadKey().KeyChar); Console.WriteLine(); if (key == 'X') { return; } if (key == 'Y') { copier.Stop(); } e.Cancel = true; } }