Don't hurt him, but hold him firmly to let him know you mean business, and that this behavior must stop now.
Say Stop, calm down, and other such phrases in a firm but not mean tone (a parenting tone, if you will), until he relaxes a little.
This example is also,.