c sharp how to properly close a window in code example Example 1: c# close window Application.Exit(); Example 2: c# window instantly close System.Console.ReadLine();