Fix heap-use-after-free when closing a scene with its builtin script open
Fix heap-use-after-free when closing a scene with its builtin script open

(cherry picked from commit 61bc7d65768ebe4baa9b2f888d656cce5109dd5b)

ex/godot,ex/godot,ex/godot,ex/godot,ex/godot,ex/godot,ex/godot,ex/godot