When you design a state machine, create a distinct initialize state and shutdown state for the program. You can also add a specific state to handle user input or provide custom error handling, depending on your program needs.
Specify one entry point and one exit point for a state machine to control the code that executes each time the state machine starts up and shuts down.
A state machine runs continuously until the condition terminal on the While Loop receives the stop value determined by the user. Directing your state machine toward a single exit rather than accounting for multiple exit points allows you to control the shutdown code that executes each time the machine stops. Using a single exit state also helps prevent accidental, premature, or partial state machine shutdowns.
If you are designing a program that implements user interface actions or contains specialized error handling, consider including these states in your state machine.