But operating systems seem already to be able to do something similar in software, since they do cut the sound to HDMI once the headphones are fully plugged in.
That's being able to detect if the plug is in. That's not the same thing as preventing a short circuit.
That's being able to detect if the plug is in. That's not the same thing as preventing a short circuit.