Fix bug for removing events in stacked modals