Check out example codes for "c# exit program". It will help you in understanding the concepts better.

Code Example 1

if (System.Windows.Forms.Application.MessageLoop) 
{
    // WinForms app
    System.Windows.Forms.Application.Exit();
}
else
{
    // Console app
    System.Environment.Exit(1);
}

Code Example 2

System.Environment.Exit(1);

Code Example 3

System.Windows.Forms.Application.ExitThread( )

Code Example 4

Application.Exit();

Learn ReactJs, React Native from akashmittal.com