Corrected the closeOverlay check