Our cows don't kick, but sometimes a new heifer will until she gets used to being milked. We use a "Cow Kan't Kick" clamp over their back and along their sides to limit their motion, but I don't like to use it for more than a few days at most. I will usually stand along side them very close and rub their back as they milk to help calm them. I don't yell or make sudden movements, and if they kick it off, I will put it back on until they are done. That way they learn that it won't be over until they are empty. If you give in and let them kick it off, they will do it all the time. I find being very close to the cow sort of intimidates them into standing still as they fear me more than the machine. I don't hit them, but I am 6'5" tall and pretty big, so they are naturally a bit scared of me. Also, if they do kick, its better to be right up against them rather than a ways away because they can't get momentum behind the kick. Sometimes I rock the cow gently side to side whenever they try to lift a leg to kick. If they try to pick up their right leg, I rock them to the right. Try to pick up the left leg, and they get rocked to the left. Doesn't always work, but it keeps them a bit off balance. Most of our cows get used to being milked after the first 3-5 milkings, but we did have a red holstein that took over a month to calm down. Must be the red hair!
I find if I start spraying and dipping the heifers the last month or so before they freshen, it really helps to get them used to being handled when being milked. I sometimes rub my hand along the bottom of their udder a few times before I spray or dip them so they get used to being touched. Its always funny the expression on their faces the first time or two that you do that. Sort of like this: