Check out example codes for "c# exit application". 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

// In a console application:
Environment.Exit(0);
// In a WPF application:
Close();

Code Example 3

System.Windows.Forms.Application.ExitThread( )

Code Example 4

Application.Exit();

Learn ReactJs, React Native from akashmittal.com