fix auto close functionality for modals and popups