In my instance, just having Windows Media Player open before launching the game prevents the bug from happening, and the game exits normally with no error code. It makes me wonder if there isn't something going on between Windows <>DirectSound <> OpenAL <> Minecraft.
The issue disappeared for me in the 1.20.3 release candidate snapshots. It remains banished.
However, I had updated my video drivers and audio drivers in an attempt to fix this prior to reporting, which did not solve the issue.