Added save on window close