### Godot version

v4.1.beta2.official [a2575cba4]

### System information

Godot v4.1.beta2 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 31.0.15.3141) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)

### Issue description

With the latest 4.1.beta2 static variables will now raise an error in console and log. No crash, only a error:
```
USER ERROR: Condition "p_elem->_root != this" is true.
   at: remove (./core/templates/self_list.h:80)
```
I don't know if pull #78138 has anything to do with it?

Anyway, if `static` keyword will removed, the error is gone.

### Steps to reproduce

Pretty simple:

Make a new scene, attach a new script and copy/paste this:

```GDScript
extends Node2D

static var my_static_int: int = 0

func _ready() -> void:
	pass
```

Run scene and close it.

### Minimal reproduction project

N/A
if (clear_data == nullptr) {
		clear_data = &data;
		is_root = true;
	}
	RBSet<GDScript *> must_clear_dependencies = get_must_clear_dependencies();
	for (GDScript *E : must_clear_dependencies) {
		clear_data->scripts.insert(E);
		E->clear(clear_data);
	}
	for (const KeyValue<StringName, GDScriptFunction *> &E : member_functions) {
		clear_data->functions.insert(E.value);
	}
	member_functions.clear();
	for (KeyValue<StringName, MemberInfo> &E : member_indices) {
		clear_data->scripts.insert(E.value.data_type.script_type_ref);
		E.value.data_type.script_type_ref = Ref<Script>();
	}
	for (KeyValue<StringName, MemberInfo> &E : static_variables_indices) {
		clear_data->scripts.insert(E.value.data_type.script_type_ref);
		E.value.data_type.script_type_ref = Ref<Script>();
	}
	static_variables.clear();
	static_variables_indices.clear();
	if (implicit_initializer) {
		clear_data->functions.insert(implicit_initializer);
		implicit_initializer = nullptr;
	}
	if (implicit_ready) {