This function is called upon an event that causes a state transition. It is assumed that the
thread running the run() function will be terminated upon completion of this function call. The
StateMachine will forcable destroy the thread after this call.