Make closeModalOnClick work correctly