I would like to be able to trap Ctrl+C in a C# console application so that I can carry out some cleanups before exiting. What is the best way of doing this?
See MSDN:
Console.CancelKeyPress Event
Article with code samples:
Ctrl-C and the .NET console application