Close when clicking outside or pressing 'esc'