System.gui.confirm() - Auto close

You can’t use scripting because those popups stop the GUI thread. So almost all other scripts won’t run, either.

Just don’t use system.gui.confirm(). At all. (Nor any of the system.gui.*Box functions.) Make a real popup window for such user interaction. Use window z-order to keep them on top if necessary. Regular popup windows allow scripts to keep running, and can’t get behind the application window.