Overlays: Fixed race condition related to clicking on the close button