removing window event listeners when modals close