private void Application_Exit(object sender, EventArgs e) { if (IsOpen) { isAppExit = true; try { Close(); } finally { isAppExit = false; } } }