Repository: microsoft/PowerToys
File: src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs (C#)

Code before:
                    {
                        POINT? p = null;
                        if (containsFlyoutPosition)
                        {
                            p = new POINT(flyout_x, flyout_y);
                        }

                        ShellPage.OpenFlyoutCallback(p);
                    }
                }
            }
            else
            {
#if DEBUG
                // For debugging purposes
                // Window is also needed to show MessageDialog
                settingsWindow = new MainWindow(isDark);
                settingsWindow.ExtendsContentIntoTitleBar = true;
                settingsWindow.Activate();
                settingsWindow.NavigateToSection(StartupPage);
                ShowMessageDialog("The application is running in Debug mode.", "DEBUG");
#else
                SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.Overview, true);
#endif
            }
        }

#if !DEBUG
        private async void ShowMessageDialogAndExit(string content, string title = null)
#else
        private async void ShowMessageDialog(string content, string title = null)
#endif
        {
            await ShowDialogAsync(content, title);
#if !DEBUG
            this.Exit();
#endif
        }

        public static Task<IUICommand> ShowDialogAsync(string content, string title = null)
        {
            var dialog = new MessageDialog(content, title ?? string.Empty);
            var handle = NativeMethods.GetActiveWindow();
            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException();
            }

            InitializeWithWindow.Initialize(dialog, handle);
            return dialog.ShowAsync().AsTask<IUICommand>();
        }

Review comment (suggestion):
```suggestion
                Exit();
#endif
```

Prevent the first instance of `Powertoys.Settings.exe` to stay opened after starting PT runner.
![image](https://github.com/microsoft/PowerToys/assets/25966642/503a1735-cc77-460a-95ee-cbfbb1c09acb)


Code after:
                    {
                        POINT? p = null;
                        if (containsFlyoutPosition)
                        {
                            p = new POINT(flyout_x, flyout_y);
                        }

                        ShellPage.OpenFlyoutCallback(p);
                    }
                }
            }
            else
            {
#if DEBUG
                // For debugging purposes
                // Window is also needed to show MessageDialog
                settingsWindow = new MainWindow(isDark);
                settingsWindow.ExtendsContentIntoTitleBar = true;
                settingsWindow.Activate();
                settingsWindow.NavigateToSection(StartupPage);
                ShowMessageDialog("The application is running in Debug mode.", "DEBUG");
#else
                /* If we try to run Settings as a standalone app, it will start PowerToys.exe if not running and open Settings again through it in the General page. */
                SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.Overview, true);
                Exit();
#endif
            }
        }

#if !DEBUG
        private async void ShowMessageDialogAndExit(string content, string title = null)
#else
        private async void ShowMessageDialog(string content, string title = null)
#endif
        {
            await ShowDialogAsync(content, title);
#if !DEBUG
            this.Exit();
#endif
        }

        public static Task<IUICommand> ShowDialogAsync(string content, string title = null)
        {
            var dialog = new MessageDialog(content, title ?? string.Empty);
            var handle = NativeMethods.GetActiveWindow();
            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException();
            }

            InitializeWithWindow.Initialize(dialog, handle);