Don't close modal dialogs when clicking outside of them

See #2999