c# make console app close after form open code example Example: c# how to exit program System.Environment.Exit(1);