I assume this is internal utility function, I would prefer it to return promise that is resolved once window is closed. With optional callback argument that is registered as a handler on the returned promise if passed.