### Godot version

508a5bf16ea50552c56539da4c96ea13fdf8853e

### System information

Windows 10, Intel i9-11900K

### Issue description

Godot runs fine in the Editor but any test run of a (3D) scene freezes the window up.
Even a test scene with just a single Node3D freezes.

All the test project runs fine with slightly older versions of master / Godot 4.1.

There are no errors but after bisecting it the problem points at changes from pr https://github.com/godotengine/godot/pull/76945 so properly some kind of thread deadlock.

![bisect_result](https://github.com/godotengine/godot/assets/52464204/85442c3c-7df2-43ca-85ef-e555055eec3d)

_edit_

Seems to be caused by ProjectSettings `threading/worker_pool/max_threads` set to 0 and `shader_compiler/shader_cache/enabled`=false

### Steps to reproduce

set ProjectSettings `threading/worker_pool/max_threads` to 0 and `shader_compiler/shader_cache/enabled`=false and testrun a scene from the Editor.

### Minimal reproduction project

[WorkerThreadPoolIssue.zip](https://github.com/godotengine/godot/files/11489032/WorkerThreadPoolIssue.zip)
if (finished_users == max_users) {
			
			task_mutex.lock();
			group_allocator.free(group);
			task_mutex.unlock();
		}
	}
	task_mutex.lock(); 
	groups.erase(p_group);
	task_mutex.unlock();
}
void WorkerThreadPool::init(int p_thread_count, bool p_use_native_threads_low_priority, float p_low_priority_task_ratio) {
	ERR_FAIL_COND(threads.size() > 0);
	if (p_thread_count < 0) {
		p_thread_count = OS::get_singleton()->get_default_thread_pool_size();
	}
	if (p_use_native_threads_low_priority) {
		max_low_priority_threads = 0;
	} else {
		max_low_priority_threads = CLAMP(p_thread_count * p_low_priority_task_ratio, 1, p_thread_count - 1);
	}
	use_native_low_priority_threads = p_use_native_threads_low_priority;
	threads.resize(p_thread_count);
	for (uint32_t i = 0; i < threads.size(); i++) {
		threads[i].index = i;
		threads[i].thread.start(&WorkerThreadPool::_thread_function, &threads[i]);
		thread_ids.insert(threads[i].thread.get_id(), i);
	}
}
void WorkerThreadPool::finish() {