added a quick hack to close dialogs if a click occurs outside the dialog