How to exit a Windows Forms Application in C#
<p>I'm writing a Windows Forms Application in C# that uses only 1 form. When I want to exit and close the application, I put the code</p>

<pre><code>    private void Defeat()
    {
        MessageBox.Show("Goodbye");
        this.Close();
    }
</code></pre>

<p>Inside the class <code>Form1 : Form</code>, which is the form class that was automaticly created by Visual Studio. But when this code runs, I get the fallowing message:</p>

<pre><code>An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll

Additional information: A generic error occurred in GDI+.
</code></pre>

<p>A picture of the message:</p>

<p><img src="http://i.stack.imgur.com/nBRpA.jpg" alt="Error message"></p>

<p>What is the problem?</p>

<p>How should I exit my application?</p>
