scripting: protect FSM execution and tracing against self-deactivation

Signed-off-by: Ruben Smits <ruben.smits@intermodalics.eu>