Stateflow    

Exiting an Active State

A state is exited (becomes inactive) in one of the following ways:

A state performs its exit action (if specified) before it becomes inactive. The state is marked inactive after the exit action has executed and completed.

The execution steps for exiting a state are as follows:

  1. If this is a parallel state, and one of its sibling states was entered before this state, exit the siblings starting with the last-entered and progressing in reverse order to the first-entered. See step 2 of Entering a State.
  2. If there are any active children, perform the exit steps on these states in the reverse order they were entered.
  3. Perform any exit actions.
  4. Mark the state as inactive.

  Executing an Active State State Execution Example