Actually, it seems this only happens when there's no audio device connected or something like that. I use a DAC amp for my headphones, and lately, when the cord is moved, it messes up everything within Windows and there's no way to fix it other than reboot, and a lot of programs just crash when trying to use them in this state (YouTube stops working, trying to close Godot Engine freezes it, then this).
Not sure if this is solely a Windows problem or some exception handling could be added for audio and such.