Totally agree that it's not async and Promises aren't right choice here, my main point was to use setTimeout together with the rest of cleanup code inside dedicated cleanup function as it's related to cleanup itself not to the program flow. Used promise just to simplify example :), here we should use other approach eg. passing function-to-be-run-after-cleanup as the parameter of the cleanup function or any other more elegant way :)