title: C# - Manually closing a forms application
body: <p>I would like to know the appropriate way to completely terminate a Forms application.  I open the form in the standard way using the code:</p>
  
  <pre><code>namespace History
  {
      static class Program
      {
          [STAThread]
          static void Main()
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(new DisplayHistory());
          }
      }
  }
  </code></pre>
  
  <p>...and here is a barebones version of the DisplayHistory function with the various things I've tried to terminate the application commented out.  The first two cause an unhandled exception stating that I cannot access a disposed object.  The third one has no effect at all, and the fourth one won't compile at all because I get an error saying that "Application does not contain a definition for Current":</p>
  
  <pre><code>public DisplayHistory()
  {
      InitializeComponent();
  
  //    this.Close();
  //    Close();
  //    Application.Exit();
  //    Application.Current.Shutdown();
  }
  </code></pre>