on closing end program c# windows.form code example Example: how to exit a program in c# Application.Exit();