I need to run a script and wait for its completion before I exit the app. The script is being run in PowerShell using node-powershell. I have tried the window.onbeforeunload function which works when I return false but returning false disables the close function. Is there a way to delay the unload for a few seconds while my script completes or another method?
Scripts emit an ‘on close’ event
Edit: Wrong module, but power shell node also has an exit event