Execute promises before exiting a process