Implement saving of main window state and quit action