It is rather confusing, but the main problem is that this is actually not a form that supports the application. The key helper class is ApplicationContext, which also appears as one of Application.Run () overloads. When you use other overloads, Run () and Run (Form), the Application class creates a hidden instance of ApplicationContext. What is global, like all properties and methods of an application.
Therefore, when you call Application.Exit (), you mark this global instance of ApplicationContext as "more inactive." Which makes the next run (Form) call complete immediately.
Instead, you can monkey with your ApplicationContext instances to solve this problem. But the template solution should use the ShowDialog () method in the login form. Also a good way to return the state of "login is good, let continue", it is useful to use DialogResult.
source share