Our kids often surprise us. At times though not in a good way. It is the emotional moment of reaction that can trip us up.
When the emotional part of the brain is stimulated, it causes our logical, thinking side to shut down. No surprise that even the best of us do and say really dumb things when we are upset.
Solution? Give yourself time to calm down and get the thinking part of your brain working again. Actually, it can be quite helpful to say to your kid "I am so upset right now that I cannot even deal with this. We will talk later!" Just make sure the talk later part happens. There is nothing wrong with kids having to "wait" to see what their consequence is.
P.S. Your kid's brain works the same way. So don't expect to work things out when they are upset either.