### Godot version

4.1.dev (094e88416ab84cc4e391703453fb46528739cd69)

### System information

Mageia 9, Linux

### Issue description

I'm seeing a crash on exit in one of my test projects, which seems to be a recent regression.

The crash happens when quitting the 3D gameplay in https://github.com/team-godog/NGJ2023_Godog

There are errors about leaking `GodotBody3D` and `GodotShape3D`, and then leaking two shaders:

```
ERROR: 5 RID allocations of type 'P11GodotBody3D' were leaked at exit.
ERROR: 4 RID allocations of type 'P12GodotShape3D' were leaked at exit.
ERROR: Pages in use exist at exit in PagedAllocator: N33RendererSceneRenderImplementation22RenderForwardClustered32GeometryInstanceSurfaceDataCacheE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: Pages in use exist at exit in PagedAllocator: N33RendererSceneRenderImplementation22RenderForwardClustered32GeometryInstanceForwardClusteredE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:170)
ERROR: 2 shaders of type SceneForwardClusteredShaderRD were never freed
   at: ~ShaderRD (servers/rendering/renderer_rd/shader_rd.cpp:708)
ERROR: FATAL: DEV_ASSERT failed  "_first == nullptr" is false.
   at: ~List (./core/templates/self_list.h:114)

Thread 1 "godot-git" received signal SIGILL, Illegal instruction.
0x0000000009c2e943 in SelfList<RendererSceneRenderImplementation::SceneShaderForwardClustered::ShaderData>::List::~List (this=0xd048958, __in_chrg=<optimized out>) at ./core/templates/self_list.h:114
114                             DEV_ASSERT(_first == nullptr);

(gdb) bt
#0  0x0000000009c2e943 in SelfList<RendererSceneRenderImplementation::SceneShaderForwardClustered::ShaderData>::List::~List (this=0xd048958, __in_chrg=<optimized out>) at ./core/templates/self_list.h:114
#1  0x0000000009c29747 in RendererSceneRenderImplementation::SceneShaderForwardClustered::~SceneShaderForwardClustered (this=0xd048958, __in_chrg=<optimized out>)
    at servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:473
#2  0x0000000009c0fc10 in RendererSceneRenderImplementation::RenderForwardClustered::~RenderForwardClustered (this=0xd046d40, __in_chrg=<optimized out>)
    at servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp:4026
#3  0x0000000009b60da2 in memdelete<RendererSceneRenderRD> (p_class=0xd046d40) at ./core/os/memory.h:109
#4  0x0000000009b5f396 in RendererCompositorRD::finalize (this=0xcc78be0) at servers/rendering/renderer_rd/renderer_compositor_rd.cpp:149
#5  0x0000000009a64601 in RenderingServerDefault::_finish (this=0xcc368b0) at servers/rendering/rendering_server_default.cpp:217
#6  0x0000000009a64839 in RenderingServerDefault::finish (this=0xcc368b0) at servers/rendering/rendering_server_default.cpp:244
#7  0x000000000584fee4 in finalize_display () at main/main.cpp:313
#8  0x0000000005868d56 in Main::cleanup (p_force=false) at main/main.cpp:3597
#9  0x00000000057dae8a in main (argc=1, argv=0x7fffffffd688) at platform/linuxbsd/godot_linuxbsd.cpp:75
```

The crash is on a `DEV_ASSERT` (so `dev_build=yes`), might not happen in a non-dev build.

Doesn't happen in 4.0.3-stable, and I don't remember seeing it a couple of weeks ago, so I expect this is a recent regression.

### Steps to reproduce

- Clone https://github.com/team-godog/NGJ2023_Godog
- Edit it with latest Godot `master`, game commit 212feb11867bb4468b357e96756fef40d904e614
- Press "Play", watch the intro (or skip with Esc), wait for the gameplay to start (takes a while to load in a dev build)
- When in game (sliding dog on a slope), press Esc to show the pause menu, and press Quit - it should crash

### Minimal reproduction project

See Steps to reproduce. It's not really minimal, I might try to narrow it down further but this is a relatively simple open source project and I think the regression can be easily pinpointed to recent changes to shader freeing.

CC @BastiaanOlij @clayjohn 
editor_export = memnew(EditorExport);
	add_child(editor_export);
	
	EditorColorMap::create();
	theme = create_custom_theme();
	DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), SNAME("Editor")));
	register_exporters();
	EDITOR_DEF("interface/editor/save_on_focus_loss", false);
	EDITOR_DEF("interface/editor/show_update_spinner", false);
	EDITOR_DEF("interface/editor/update_continuously", false);
	EDITOR_DEF("interface/editor/localize_settings", true);
	EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", true);
	EDITOR_DEF_RST("interface/inspector/default_property_name_style", EditorPropertyNameProcessor::STYLE_CAPITALIZED);
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_property_name_style", PROPERTY_HINT_ENUM, "Raw,Capitalized,Localized"));
	EDITOR_DEF_RST("interface/inspector/default_float_step", 0.001);
	
	
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "interface/inspector/default_float_step", PROPERTY_HINT_RANGE, "0.0000001,1,0.0000001"));
	EDITOR_DEF_RST("interface/inspector/disable_folding", false);
	EDITOR_DEF_RST("interface/inspector/auto_unfold_foreign_scenes", true);
	EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false);
	EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true);
	EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
	PackedStringArray open_in_new_inspector_defaults;
	
	open_in_new_inspector_defaults.push_back("Script");
	
	open_in_new_inspector_defaults.push_back("MeshLibrary");
	EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", open_in_new_inspector_defaults);
	EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);