@@ -51,42 +51,42 @@ public void Application_Startup(object sender, StartupEventArgs e)
5151 if ( IsAdministrator ( ) == false )
5252 {
5353 ElevateAsAdmin ( ) ;
54- Environment . Exit ( 740 ) ;
54+ Configuration . SafeShutdown ( 740 ) ;
5555 return ;
5656 }
5757
5858 var installer = new UserInterface . Setup . Installer ( ) ;
5959 installer . ShowDialog ( ) ;
60- Environment . Exit ( 0 ) ;
60+ Configuration . SafeShutdown ( 0 ) ;
6161 break ;
6262 }
6363 case > 0 :
6464 {
6565 if ( args . Contains ( "--debug" ) )
6666 IsDebug = true ;
6767 if ( args . Contains ( "-ToastActivated" ) ) // Clicked on notification, ignore it.
68- Environment . Exit ( 0 ) ;
68+ Configuration . SafeShutdown ( 0 ) ;
6969 if ( args . Contains ( "--control-panel" ) )
7070 {
7171 if ( IsAdministrator ( ) == false )
7272 {
7373 ElevateAsAdmin ( string . Join ( " " , args ) ) ;
74- Environment . Exit ( 740 ) ;
74+ Configuration . SafeShutdown ( 740 ) ;
7575 return ;
7676 }
7777
7878 // Check if user allowed opening the control panel
7979 if ( RegistryConfig . GetKey ( "ControlPanelIsInstalled" ) != "True" )
8080 {
8181 Logging . Log ( "Control Panel is not allowed on this system, exiting ..." , Logging . LogLevel . ERROR ) ;
82- Environment . Exit ( 1 ) ;
82+ Configuration . SafeShutdown ( 1 ) ;
8383 return ;
8484 }
8585
8686 Configuration . InitialEnvironment ( ) ;
8787 var controlCenter = new UserInterface . ControlPanel . ControlPanel ( ) ;
8888 controlCenter . ShowDialog ( ) ;
89- Environment . Exit ( 0 ) ;
89+ Configuration . SafeShutdown ( 0 ) ;
9090 }
9191
9292 if ( args . Contains ( "--copilot-dock" ) )
@@ -98,14 +98,14 @@ public void Application_Startup(object sender, StartupEventArgs e)
9898 DebugMessage . DisplayDebugMessage ( "GoAwayEdge" ,
9999 $ "Opening AI Provider '{ Configuration . AiProvider } ' (Triggered with argument) ...") ;
100100 UserInterface . CopilotDock . InterfaceManager . ShowDock ( ) ;
101- Environment . Exit ( 0 ) ;
101+ Configuration . SafeShutdown ( 0 ) ;
102102 }
103103 else
104104 {
105105 IsDebug = true ;
106106 DebugMessage . DisplayDebugMessage ( "GoAwayEdge" ,
107107 "You cannot open the Copilot dock if your AI provider is set to default" ) ;
108- Environment . Exit ( 1 ) ;
108+ Configuration . SafeShutdown ( 1 ) ;
109109 }
110110 }
111111
@@ -149,36 +149,36 @@ public void Application_Startup(object sender, StartupEventArgs e)
149149 if ( IsAdministrator ( ) == false )
150150 {
151151 var elevatedProcess = ElevateAndWait ( string . Join ( " " , args ) ) ;
152- Environment . Exit ( elevatedProcess ) ;
152+ Configuration . SafeShutdown ( elevatedProcess ) ;
153153 return ;
154154 }
155155
156156 Configuration . InstallControlPanel = true ;
157157 var result = InstallRoutine . Install ( null ) ;
158- Environment . Exit ( result ) ;
158+ Configuration . SafeShutdown ( result ) ;
159159 }
160160 if ( args . Contains ( "-u" ) )
161161 {
162162 if ( IsAdministrator ( ) == false )
163163 {
164164 var elevatedProcess = ElevateAndWait ( string . Join ( " " , args ) ) ;
165- Environment . Exit ( elevatedProcess ) ;
165+ Configuration . SafeShutdown ( elevatedProcess ) ;
166166 return ;
167167 }
168168 var result = InstallRoutine . Uninstall ( null ) ;
169- Environment . Exit ( result ) ;
169+ Configuration . SafeShutdown ( result ) ;
170170 }
171171 if ( args . Contains ( "--update" ) )
172172 {
173173 var statusEnv = Configuration . InitialEnvironment ( ) ;
174- if ( statusEnv == false ) Environment . Exit ( 1 ) ;
174+ if ( statusEnv == false ) Configuration . SafeShutdown ( 1 ) ;
175175
176176 // Check for app update
177177 var updateAvailable = Updater . CheckForAppUpdate ( ) ;
178178
179179 var updateSkipped = RegistryConfig . GetKey ( "SkipVersion" ) ;
180180 if ( updateAvailable == updateSkipped )
181- Environment . Exit ( 0 ) ;
181+ Configuration . SafeShutdown ( 0 ) ;
182182
183183 if ( ! string . IsNullOrEmpty ( updateAvailable ) )
184184 {
@@ -194,17 +194,17 @@ public void Application_Startup(object sender, StartupEventArgs e)
194194 case "Btn1" :
195195 {
196196 var updateResult = Updater . UpdateClient ( ) ;
197- if ( ! updateResult ) Environment . Exit ( 0 ) ;
197+ if ( ! updateResult ) Configuration . SafeShutdown ( 0 ) ;
198198 break ;
199199 }
200200 case "Btn3" :
201201 RegistryConfig . SetKey ( "SkipVersion" , updateAvailable ) ;
202- Environment . Exit ( 0 ) ;
202+ Configuration . SafeShutdown ( 0 ) ;
203203 break ;
204204 }
205205 }
206206
207- Environment . Exit ( 0 ) ;
207+ Configuration . SafeShutdown ( 0 ) ;
208208 }
209209
210210 break ;
@@ -213,7 +213,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
213213
214214 Configuration . InitialEnvironment ( ) ;
215215 ArgumentParse . Parse ( args ) ;
216- Environment . Exit ( 0 ) ;
216+ Configuration . SafeShutdown ( 0 ) ;
217217 }
218218
219219 private static void ElevateAsAdmin ( string ? arguments = null )
0 commit comments