My practice is to reflect on when things like this happen. We have one 3yo son but issues do arise where we get upset, and reflecting on them and preparing myself for the next time helps me address what he needs to not do whatever it is that upset me, and for me to not get upset which makes him upset.
I guess it's not so strange now but when I started parenting I figured my parents' approach would be best, like expecting kids to do their work because it's basically their job.
What I didn't expect is how powerful the word "please" is.
Seriously, I'd been trying to get him to do small tasks when he was about two and understanding us, but wouldn't ever, EVER do it. I'd talked with a teacher who mentioned her class listens to her because she asks them politely and other teachers who don't have unruly classes. And so I finally caved and said "...can you please put your dishes in the sink?"
The difference was night and day. Immediately, he picked up his dishes and put them in the sink. Since then, I think we've done an OK job of inviting him to be involved in chores and tasks because anytime he realizes we're working on something the first thing he says is "can I help you?"
Anyway, point is you can learn so much just by paying attention, mindful reflection, careful preparation, and some study mixed in there. And as someone else said, having the humility to acknowledge to your kids' face that you were wrong goes a long way.