Back button and save state after exit