I actually feel this could be abused by silently popping up the DevConsole when the player attempts to leave. As for detecting when the player actually requests to leave through the close button, I’m not sure.
Also prompting this up when you attempt to leave through the X button is really bad UX and should be removed from the Lua App.