Add quit method that saves everything before quiting