### 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
p_extensions->push_back("gd");
}
bool ResourceFormatLoaderGDScript::handles_type(const String &p_type) const {
	return (p_type == "Script" || p_type == "GDScript");
}
String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) const {
	String el = p_path.get_extension().to_lower();
	if (el == "gd") {
		return "GDScript";
	}
	return "";
}
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
	Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ);
	ERR_FAIL_COND_MSG(file.is_null(), "Cannot open file '" + p_path + "'.");
	String source = file->get_as_utf8_string();
	if (source.is_empty()) {
		return;
	}
	GDScriptParser parser;
	if (OK != parser.parse(source, p_path, false)) {
		return;
	}
	for (const String &E : parser.get_dependencies()) {
		p_dependencies->push_back(E);
	}
}
Error ResourceFormatSaverGDScript::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {