diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs index 4ba0885f06..ff477163a5 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs @@ -80,7 +80,7 @@ namespace Microsoft.PowerToys.Settings.UI.Runner shellPage.Refresh(); } - // If the window is open, explicity force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 + // XAML Islands: If the window is open, explicity force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 if (isOpen) { Show(); @@ -90,6 +90,13 @@ namespace Microsoft.PowerToys.Settings.UI.Runner private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { isOpen = false; + + // XAML Islands: If the window is closed while minimized, exit the process. Required to avoid process not terminating issue - https://github.com/microsoft/PowerToys/issues/4430 + if (WindowState == WindowState.Minimized) + { + // Run Environment.Exit on a separate task to avoid performance impact + System.Threading.Tasks.Task.Run(() => { Environment.Exit(0); }); + } } } }