Allow on_exit_state to cancel state transitions and use it to simplify.