c# make a fonction to leave app code example
Example 1: c# how to exit program
System.Environment.Exit(1);
Example 2: how to close an application in c#
this.Close();
//This only close the current form or window that you are using.
System.Environment.Exit(1);
this.Close();
//This only close the current form or window that you are using.