This is analogous to a charging capacitor except that instead of a battery, we have a discharging capacitor. We assume some wire resistance ##R##. If we let ##q(t)## be the instantaneous charge on the initially uncharged capacitor and ##q_0## the initial charge on the charged capacitor, then the Kirchhoff voltage equation is $$\frac{q_0-q}{C}-iR-\frac{q}{C}=0~~~~~\left(i=\frac{dq}{dt}\right).$$The solution of this differential equation is$$q(t)=\frac{1}{2}q_0e^{\frac{-2t}{RC}}.$$The energy dissipated in the resistor is $$E_{\text{loss}}=\int_0^\infty \left(\frac{dq}{dt}\right)^2R~dt=\left(\frac{q_0}{RC}\right)^2R\int_0^\infty e^{\frac{-4t}{RC}}dt=\frac{1}{4}\frac{q_0^2}{C}.$$Doing it by energy considerations, $$U_{\text{before}}=\frac{1}{2C}q_0^2~;~~U_{\text{after}}=\frac{1}{2C}\left(\frac{q_0}{2}\right)^2+\frac{1}{2C}\left(\frac{q_0}{2}\right)^2=\frac{1}{4}\frac{q_0^2}{C}.$$Therefore, $$U_{\text{before}}=U_{\text{after}}+E_{\text{loss}}.$$ Note that this result is
independent of the assumed wire resistance ##R## so one can let it become arbitrarily small and the result would be the same. Of course there will be radiative losses too as others have observed, which are ignored in the simple model presented here. However, these will be under the ##E_{\text{loss}}## umbrella and will come at the expense of the Ohmic losses. In short (the pun is intentional), you can't beat
Poynting's theorem.