void MainWindow_Exit(object?sender, ControlledApplicationLifetimeExitEventArgs e) { if (hasExited) { return; } hasExited = true; SettingsFile.SaveSettings(); }