Use "beforeAppClose" event to record all long running promises and quit only if all of them are done.