Fixed modal so it can be closed with ESC

* Fixes: #5343
Merge pull request #6013 from jvanbaarsen/modal-fix

Fixed modal so it can be closed with ESC