@@ -1731,10 +1731,18 @@ define(function (require, exports, module) {
17311731 . finally ( ( ) => {
17321732 raceAgainstTime ( _safeNodeTerminate ( ) )
17331733 . finally ( ( ) => {
1734- // In Electron, use allowClose() to bypass the close handler
1735- // (which would otherwise trigger another cleanup cycle).
1734+ // In Electron multi-window case, use allowClose() to bypass
1735+ // the close handler (which would otherwise trigger another
1736+ // cleanup cycle). But for last window, closeWindow() calls
1737+ // quitApp() (no loop) and runs quitTimeAppUpdateHandler.
17361738 if ( window . __ELECTRON__ ) {
1737- window . electronAPI . allowClose ( ) ;
1739+ Phoenix . app . getPhoenixInstanceCount ( ) . then ( count => {
1740+ if ( count === 1 ) {
1741+ Phoenix . app . closeWindow ( ) ;
1742+ } else {
1743+ window . electronAPI . allowClose ( ) ;
1744+ }
1745+ } ) ;
17381746 } else {
17391747 Phoenix . app . closeWindow ( ) ;
17401748 }
@@ -2276,11 +2284,19 @@ define(function (require, exports, module) {
22762284 raceAgainstTime ( _safeNodeTerminate ( ) )
22772285 . finally ( ( ) => {
22782286 closeInProgress = false ;
2279- // In Electron, we must call allowClose() to complete the original
2280- // close request (sets forceClose=true) . Calling closeWindow() would
2287+ // In Electron multi-window case , we must call allowClose() to
2288+ // complete the original close request . Calling closeWindow() would
22812289 // trigger a new close sequence and cause an infinite loop.
2290+ // But for last window, closeWindow() calls quitApp() (no loop),
2291+ // and we need it to run quitTimeAppUpdateHandler.
22822292 if ( window . __ELECTRON__ ) {
2283- window . electronAPI . allowClose ( ) ;
2293+ Phoenix . app . getPhoenixInstanceCount ( ) . then ( count => {
2294+ if ( count === 1 ) {
2295+ Phoenix . app . closeWindow ( ) ;
2296+ } else {
2297+ window . electronAPI . allowClose ( ) ;
2298+ }
2299+ } ) ;
22842300 } else {
22852301 Phoenix . app . closeWindow ( ) ;
22862302 }
0 commit comments