Handling Ctrl+C in a C# console tool (Designer SDK)

Handling exceptions is not enough to make clean up (quit Designer). The following code handles Ctrl+C.

using System;
using Designer;
namespace ConsoleApplication1
{
    class Program
    {
        delegate void CleanUpMethod();

        static void Main(string[] args)
        {
            Application application = new Application();

            CleanUpMethod cleanUp = delegate { application.Quit(); };
            Console.CancelKeyPress += delegate { cleanUp(); };

            try
            {
                application.LogonDialog();

                // ... some code here ...
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                cleanUp();
            }
        }
    }
}