### Godot version

Godot 4.1 e709ad4d6407e52dc62f00a471d13eb6c89f2c4c

### System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

### Issue description

I have a `print_line` in the destructor of a custom class derived from `Node3D`. I use it in verbose mode to track when things happen. In previous versions, it worked fine. But in Godot 4.1, closing the editor crashes:

```
Exception has occurred: W32/0xC0000005
Unhandled exception thrown: read access violation.
this was 0xFFFFFFFFFFFFFFFF.

godot.windows.editor.dev.x86_64.exe!CowData<EditorLog::LogMessage>::_get_size() Line 81 (godot4_fork\core\templates\cowdata.h:81)
godot.windows.editor.dev.x86_64.exe!CowData<EditorLog::LogMessage>::size() Line 131 (godot4_fork\core\templates\cowdata.h:131)
godot.windows.editor.dev.x86_64.exe!Vector<EditorLog::LogMessage>::size() Line 93 (godot4_fork\core\templates\vector.h:93)
godot.windows.editor.dev.x86_64.exe!EditorLog::_process_message(const String & p_msg, EditorLog::MessageType p_type) Line 216 (godot4_fork\editor\editor_log.cpp:216)
godot.windows.editor.dev.x86_64.exe!EditorLog::add_message(const String & p_msg, EditorLog::MessageType p_type) Line 243 (godot4_fork\editor\editor_log.cpp:243)
godot.windows.editor.dev.x86_64.exe!EditorNode::_print_handler_impl(const String & p_string, bool p_error, bool p_rich) Line 6651 (godot4_fork\editor\editor_node.cpp:6651)
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_static<String const &,bool,bool,0,1,2>(void(*)(const String &, bool, bool) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0,1,2> __formal) Line 777 (godot4_fork\core\variant\binder_common.h:777)
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_static_ret<String const &,bool,bool>(void(*)(const String &, bool, bool) p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error) Line 847 (godot4_fork\core\variant\binder_common.h:847)
godot.windows.editor.dev.x86_64.exe!CallableCustomStaticMethodPointerRet<void,String const &,bool,bool>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 309 (godot4_fork\core\object\callable_method_pointer.h:309)
godot.windows.editor.dev.x86_64.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 51 (godot4_fork\core\variant\callable.cpp:51)
godot.windows.editor.dev.x86_64.exe!CallableCustomBind::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 145 (godot4_fork\core\variant\callable_bind.cpp:145)
godot.windows.editor.dev.x86_64.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 51 (godot4_fork\core\variant\callable.cpp:51)
godot.windows.editor.dev.x86_64.exe!CallQueue::_call_function(const Callable & p_callable, const Variant * p_args, int p_argcount, bool p_show_error) Line 220 (godot4_fork\core\object\message_queue.cpp:220)
godot.windows.editor.dev.x86_64.exe!CallQueue::flush() Line 322 (godot4_fork\core\object\message_queue.cpp:322)
godot.windows.editor.dev.x86_64.exe!Main::cleanup(bool p_force) Line 3562 (godot4_fork\main\main.cpp:3562)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 184 (godot4_fork\platform\windows\godot_windows.cpp:184)
godot.windows.editor.dev.x86_64.exe!_main() Line 204 (godot4_fork\platform\windows\godot_windows.cpp:204)
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 218 (godot4_fork\platform\windows\godot_windows.cpp:218)
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 232 (godot4_fork\platform\windows\godot_windows.cpp:232)
godot.windows.editor.dev.x86_64.exe!invoke_main() Line 107 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:107)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main_seh() Line 288 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main() Line 331 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331)
godot.windows.editor.dev.x86_64.exe!WinMainCRTStartup(void * __formal) Line 17 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_winmain.cpp:17)
kernel32.dll!00007ffdcb657614() (Unknown Source:0)
ntdll.dll!00007ffdcb8c26b1() (Unknown Source:0)
```

### Steps to reproduce

My own case is in C++, but it can be reproduced with GDScript.

Have a scene with a node having the following script on it:

```gdscript
@tool
extends Node3D

func _notification(what):
	if what == NOTIFICATION_PREDELETE:
		print("Destroying ", name)
```

Have that scene open, and close the editor.

Now unfortunately you might not notice anything depending on how your OS handles that (as with many crashes occurring on exit).
I work with debug builds and that definitely makes the crash visible in the debugger. I also use the following command line to build Godot on Windows:
```
scons p=windows target=editor dev_build=yes warnings=all werror=yes debug_crt=yes -j4
```


### Minimal reproduction project

[PrintInNodeDestructor.zip](https://github.com/godotengine/godot/files/12062273/PrintInNodeDestructor.zip)
Open the project, open the scene, then close the editor.
editor_layout_save_delay_timer->start();
}
void EditorNode::_dock_split_dragged(int ofs) {
	editor_layout_save_delay_timer->start();
}
void EditorNode::_load_editor_layout() {
	Ref<ConfigFile> config;
	config.instantiate();
	Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg"));
	if (err != OK) { 
		
		TreeItem *root = FileSystemDock::get_singleton()->get_tree_control()->get_item_with_metadata("res:", 0);
		if (root) {
			root->set_collapsed(false);
		}
		if (overridden_default_layout >= 0) {
			_layout_menu_option(overridden_default_layout);
		}
		return;
	}
	_load_docks_from_config(config, "docks");
	_load_open_scenes_from_config(config);
	_load_central_editor_layout_from_config(config);
	editor_data.set_plugin_window_layout(config);
}
void EditorNode::_update_dock_slots_visibility(bool p_keep_selected_tabs) {