We are only humans and we do get emotional at times. All we could do is to try our best to stay calm and sane with our kids. When it's not working, then I guess best is to just walk away for a bit to give ourselves and our kids chance to calm down.
It's easier said than done, I know. Sometimes I would lose patience and yell as well and I would regret yelling afterwards. But all I could do is to remind myself to try again and be more patience tomorrow.