My brain hurts, is there a simpler version?
You have an ideal capacitor, charged to some voltage. You connect both ends, which empties it.
Where did all the energy go?
The answer is that there's no such thing as an ideal capacitor or an ideal wire. There are a few effects you can't avoid, but most importantly there are tiny bits of internal resistance that usually go ignored. In a short circuit, they become important, and will turn all the energy into heat.