game:BindToClose() hangs infinitely when using coroutine.yield()

System Information:
AMD Ryzen 7 5700G
32 GB DDR4
NVIDIA GeForce RTX 3060 Ti

game:BindToClose(function()
	local thread = coroutine.running()
	task.delay(3, function()
		coroutine.resume(thread)
		warn(coroutine.status(thread)) -- dead
	end)
	
	coroutine.yield()
end)

Expected behavior

I expect the server to shutdown once the thread is resumed after 3 seconds, but it seems to hang infinitely in game, and for 30 seconds in studio

2 Likes