Accept and save current state when closing