It's not only the batteries that have exploded. The zero internal resistance of the wire has dissipated a power of V^2/R = (12 V  9 V)^2 / 0 ohms = infinity watts. That's enough heat to vaporize the universe.
You can get the same effect if you take an ideal current source, don't connect to anything, and turn it on. Pushing any required current through an infinite resistance, the power dissipated becomes infinity.
