Handle correctly opening, saving, closing and exiting from GUI