private void MainWindow_OnClosing(object sender, CancelEventArgs e) { foreach (var tab in MainTabControl.Items) { if (!((XivMonTab)((TabItem)tab).Content).IsCloseAllowed()) { MessageBoxResult res = MessageBox.Show("One or more tabs have captured packets that were not yet saved.\nDo you want to quit without saving?", "Unsaved Packets", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.No) { e.Cancel = true; return; } else { foreach (var closeTab in MainTabControl.Items) { ((XivMonTab)((TabItem)closeTab).Content).StopCapture(); } LogView.Close(); Environment.Exit(0); } } } LogView.Close(); Environment.Exit(0); }