Automatically save/restore main window state