Better close function and esc keybindings