close system c# code example Example 1: c# how to exit program System.Environment.Exit(1); Example 2: how to close a form c# this.Close();