Fixing bug when clicking outside of modal dialog