diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index e08961564d5..944f4f052ca 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1724,6 +1724,12 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { S->get().erase(script); if (S->get().size() == 0) { library_script_users.erase(S); + + Map>::Element *G = library_gdnatives.find(script->lib_path); + if (G) { + G->get()->terminate(); + library_gdnatives.erase(G); + } } } #ifndef NO_THREADS