Application.Run
using System; using System.Windows.Forms; public class MainClass : System.Windows.Forms.Form { public MainClass() { Application.ApplicationExit += new EventHandler(Form_OnExit); } [STAThread] static void Main() { Application.Run(new MainClass()); } private void Form_OnExit(object sender, EventArgs evArgs) { Console.WriteLine("Exit"); } }