Stop your console app the nice way

This would be obvious for someone. Posting it just in case :)

    class Program
    {
        private static readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
 
        static void Main(string[] args)
        {
            Console.CancelKeyPress += OnCancelKeyPress;
 
            //TODO: do work here
            AutoResetEvent.WaitOne();
            //TODO: shutdown here
        }
 
        private static void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e)
        {
            e.Cancel = true;
            AutoResetEvent.Set();
        }
    }