### Godot version

4.2.rc2 (1ba920fada9efc8c4476ded50fe673b8db541366)

### System information

Mageia 9 - Vulkan (Forward+) - dedicated AMD Radeon RX Vega M GL Graphics (RADV VEGAM) () - Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz (8 Threads)

### Issue description

I found one more case where the GDScript thread bookkeeping stuff crashes :(

Thankfully so far it seems reproducible in a fairly niche use case, so may not be critical for 4.2.

It happens when running Godot from the console, and having the editor project running as a child process, with the debugger connected.

If I send SIGINT (Ctrl+C) to terminate the two Godot instances (which I often do when testing MRPs, etc.), I get this crash:
```
$ godot-git -e
Godot Engine v4.2.rc.custom_build.5df986796 - https://godotengine.org
Found discrete GPU, setting DRI_PRIME=1 to use it.
Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.
OpenGL API 4.6 (Core Profile) Mesa 23.1.7 - Compatibility - Using Device: AMD - AMD Radeon RX Vega M GL Graphics (vegam, LLVM 15.0.6, DRM 3.52, 6.4.16-desktop-3.mga9)
 
Godot Engine v4.2.rc.custom_build.5df986796 - https://godotengine.org
OpenGL API 4.6 (Core Profile) Mesa 23.1.7 - Compatibility - Using Device: AMD - AMD Radeon RX Vega M GL Graphics (vegam, LLVM 15.0.6, DRM 3.52, 6.4.16-desktop-3.mga9)
 
^C
ERROR: Caller thread can't call this function in this node (/root). Use call_deferred() or call_thread_group() instead.
   at: propagate_notification (./scene/main/node.cpp:2236)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.rc.custom_build (5df98679672c12d96b4ac4d96ee17f1559207401)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[akien@cauldron TestMinimal]$ [1] /lib64/libc.so.6(+0x36960) [0x7fb43efcb960] (??:0)
[2] /lib64/libc.so.6(pthread_mutex_lock+0) [0x7fb43f01b4d0] (??:0)
[3] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.editor.dev.x86_64() [0x571b577] (/usr/include/c++/12/x86_64-mageia-linux/bits/gthr-default.h:749)
[4] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.editor.dev.x86_64() [0x571b5c7] (/usr/include/c++/12/x86_64-mageia-linux/bits/gthr-default.h:812)
[5] std::recursive_mutex::lock() (/usr/include/c++/12/mutex:108)
[6] std::unique_lock<std::recursive_mutex>::lock() (/usr/include/c++/12/bits/unique_lock.h:140)
[7] std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) (/usr/include/c++/12/bits/unique_lock.h:70)
[8] GDScript::_fixup_thread_function_bookkeeping() (/home/akien/Projects/godot/godot.git/./core/os/mutex.h:129)
[9] GDScriptLanguage::thread_exit() (/home/akien/Projects/godot/godot.git/./modules/gdscript/gdscript.cpp:2111)
[10] ScriptServer::thread_exit() (/home/akien/Projects/godot/godot.git/./core/object/script_language.cpp:298 (discriminator 3))
[11] Thread::callback(unsigned long, Thread::Settings const&, void (*)(void*), void*) (/home/akien/Projects/godot/godot.git/./core/os/thread.cpp:64)
[12] void std::__invoke_impl<void, void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(std::__invoke_other, void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) (/usr/include/c++/12/bits/invoke.h:61)
[13] std::__invoke_result<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>::type std::__invoke<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) (/usr/include/c++/12/bits/invoke.h:97)
[14] void std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> >::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul>) (/usr/include/c++/12/bits/std_thread.h:279)
[15] std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> >::operator()() (/usr/include/c++/12/bits/std_thread.h:286)
[16] std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> > >::_M_run() (/usr/include/c++/12/bits/std_thread.h:231)
[17] /home/akien/Projects/godot/godot.git/bin/godot.linuxbsd.editor.dev.x86_64() [0xa304fd3] (/home/iurt/rpmbuild/BUILD/gcc-12.3.0/obj-x86_64-mageia-linux/x86_64-mageia-linux/libstdc++-v3/include/bits/unique_ptr.h:95)
[18] /lib64/libc.so.6(+0x838da) [0x7fb43f0188da] (??:0)
[19] /lib64/libc.so.6(+0xff48c) [0x7fb43f09448c] (??:0)
-- END OF BACKTRACE --
================================================================
```

Can't easily get a gdb stacktrace as it makes Godot handle SIGINT differently (to drop to the gdb console instead of exiting).

There might be other ways to trigger this crash, it may just boil down to not handling abrupt closing well enough.

The bug seems reproducible in any project with a main scene defined (so you can run it from the editor), and doesn't even need GDScript scripts.

### Steps to reproduce

- Create new project, with a simple main scene (e.g. just Node2D, no scripts)
- Open terminal, run Godot editor on that project (`godot -e`)
- Run the project from the editor
- In the terminal, send SIGINT with Ctrl+C
- Godot should close (as expected) but with a stacktrace

### Minimal reproduction project

[TestMinimal.zip](https://github.com/godotengine/godot/files/13466621/TestMinimal.zip)
if (_signals.has(p_signal)) {
		return true;
	}
	if (base.is_valid()) {
		return base->has_script_signal(p_signal);
	}
#ifdef TOOLS_ENABLED
	else if (base_cache.is_valid()) {
		return base_cache->has_script_signal(p_signal);
	}
#endif
	return false;
}
void GDScript::_get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const {
	for (const KeyValue<StringName, MethodInfo> &E : _signals) {
		r_list->push_back(E.value);
	}
	if (!p_include_base) {
		return;
	}
	if (base.is_valid()) {
		base->get_script_signal_list(r_list);
	}
#ifdef TOOLS_ENABLED
	else if (base_cache.is_valid()) {
		base_cache->get_script_signal_list(r_list);
	}
#endif
}
void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const {