I can’t wrap my head around how some believe that physical punishment of a child is ok in any circumstances. At school, at home, anywhere. Doesn’t matter. Don’t hit children.
It’s extremely primitive, and you’ve only shown your own desperation and inability to handle the situation. Find a better solution.