in my application, the user is first presented with the log in screen, and the form that shows up after you log in has a Menu Bar. On that menu bar are 2 items: \"log out\" and
Apply the below code where you want to make code to exit application.
System.Windows.Forms.Application.Exit( )