Hi Ricardo,
The gen method, which triggers a state machine big-step, is synchronous. After the call to gen completes, the state machine instance relinquishes the thread and does not do any work.
It’s possible that timers might have been scheduled during your call to gen, either through JavaScript’s setTimeout function, or using <send>/@delay, and so you will want a way to make sure that these delayed calls to gen do not trigger subsequent transitions. The best approach right now would be to use SCXML semantics, and create a final state, then create a top-level state with a transition that targets this final state. When the SCION instance is in a final state, it will not longer respond to events. You could also add onentry actions to the final state to clean up your timers using <cancel> and clearTimeout, respectively, if you want to, but I can only think of one edge case where this would be important: if you have triggered a setTimeout from within the state machine that has side effects on objects passed into the state machine from outside of the state machine. In that case, you would probably want to make sure you cancel the setTimeout, and you would need to handle this explicitly in your state machine code.
One consequence of this technique is that, when you transition from the current configuration to the final state, all of the exit actions of the states in the state machine's current configuration will be executed, which may be undesirable, particularly if your SCXML has exit actions which either: a) have side effects outside of the state machine (e.g. if the actions reference objects which have been passed into the state machine), or b) are computationally expensive.
Please let me know if you can envision a scenario where a final state would not work, and a stop method on the state machine instance would be needed.
Thanks,
Jake