C# How to terminate application.run()
<p>I would like to know, how to terminate a program using, for example, the escape key. 
In general, what I have to do to stop it after the application.run(..)? </p>

<p>How can I insert this</p>

<p>private void myForm_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { 
           if (e.KeyCode == Keys.Escape) { 
               Application.Exit(); 
            } 
        } 
in the code below</p>

<p>static void Main()
        {</p>

<pre><code>        using (WinForm new_form = new WinForm())
        {
            new_form.InitializeComponent();
            new_form.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
            new_form.InitializeDevice();
            new_form.LoadSurfaces();
            new_form.Set3D();
            Application.Run(new_form);
         }
</code></pre>

<p>}</p>
