c# close window

C#
Application.Exit();
Source

Also in C#: