fix(util/thread_script_state): make sure system does not crash during
finalization