MZ Problems exiting the game with script call

Heyo all,

It seems like, since the last update, SceneManager.exit(); no longer exits the game.

I tried a couple things to test it, including turning off plugins, but it does seem tied to the update. On a blank project with an older corescript, that script closes the window like I'd expect. On the same project but updated to 1.4.4, everything freezes but the window stays open.

Has anybody else run into this? Is there a solution or different script I could try that might work? I'd like to keep using 1.4.4, as it seems to help the editor not crash on me, but not being able to exit, while not a huge deal, is kind of a bummer.
I can confirm, I have both the 1.4.0 and 1.4.4 projects. The exit function doesn't work in 1.4.4. I haven't begun to investigate why, however.
does the basic function (like MV) dont work which is just "exit();" or close();
which seems to work, I dont know MZ, so I cannot test it though.
Spoiler: Technical preamble
v1.4.4 added a listener for the Node-webkit Window's close event (main.js, Main#hookNwjsClose) in order to fully terminate the application. This seems to be creating the problem in some way, because removing the content of that method allows SceneManager.exit to function correctly again.

SceneManager.terminate (invoked following SceneManager.exit) uses the native close method to close the game window. I'm not sure how this propagates to the NWJS/app window, but a quick test suggests that it doesn't trigger the close event listener as added by hookNwjsClose. Maybe the event is still being intercepted but the listener is not being triggered for some reason...? I think we just need to manually quit the app in the terminate method.

Try loading this as a plugin/override:
JavaScript:
SceneManager.terminate = function() {
    Utils.isNwjs() ? nw.App.quit() : window.close();
};
I.e. "if in NWJS mode (standalone app) then try to quit the application, otherwise just close the tab/window". It seems to work for me, i.e. the game window(s) close~

Edit 2023-03-06: this was fixed in MZ v1.5.0. 👋
Spoiler: Technical preamble
v1.4.4 added a listener for the Node-webkit Window's close event (main.js, Main#hookNwjsClose) in order to fully terminate the application. This seems to be creating the problem in some way, because removing the content of that method allows SceneManager.exit to function correctly again.

SceneManager.terminate (invoked following SceneManager.exit) uses the native close method to close the game window. I'm not sure how this propagates to the NWJS/app window, but a quick test suggests that it doesn't trigger the close event listener as added by hookNwjsClose. Maybe the event is still being intercepted but the listener is not being triggered for some reason...? I think we just need to manually quit the app in the terminate method.

Try loading this as a plugin/override:
JavaScript:
SceneManager.terminate = function() {
    Utils.isNwjs() ? nw.App.quit() : window.close();
};
I.e. "if in NWJS mode (standalone app) then try to quit the application, otherwise just close the tab/window". It seems to work for me, i.e. the game window(s) close~
That worked perfectly, and thanks for the time and effort you put into figuring out how to make it happen; now people can happily quit playing my game any time they want! ...wait...

Original thread: https://forums.rpgmakerweb.com/threads/problems-exiting-the-game-with-script-call.145477/