Fix directory watching and close dialog boxes when clicking outside of them