c# how to make button close application code example Example: c# how to exit program System.Environment.Exit(1);