How to stop a horse from kicking
Horses that kick can be extremely dangerous. Owners should be wary of the horse and careful in all situations to be sure that they and any others are safe. Punishment, although often the first step owners take, doesn't often work when dealing with horses that kick. The first step is trying to figure out why your horse is lashing out and take it from there.
Why your horse is kicking
Some horses kick out at people and things because they feel threatened. Horses that kick out in their stall may have at one time been punished in their stalls and therefore feel threatened when someone enters. They may also feel territorial over their stall and their food if they have had to defend that from another horse. If the horse kicks out in the crossties is possible that they have been hurt by some action previously that is close to the action you are doing when they kick out. Don't discount the fact that the horse may actually be in pain. Many horse's kick out or buck under saddle because of back pain so if the behavior is out of character be sure to check for any pain the horse may be experiencing.
What to do about it
The most important thing when dealing with a horse that kicks is to stay safe. If the horse kicks in his stall only enter the stall when you are sure the horse will allow you to approach his head. If the horse kicks in the crossties pay attention to his body language so that you can be aware of when the horse is tensing to kick out.
If the horse is one that kicks in his stall you should begin by asking the horse to turn and face you. Bring a treat with you, such as a carrot that has an audible snap, or a bucket of grain. As soon as the horse begins to turn toward you praise him. If the horse seems threatening make sure you are out of range and wait for his attitude to change. This may take a lot of time but be patient. Eventually the horse will look forward to you coming to his stall and will cease to act aggressive. Some horses though, especially those that have been badly abused, will always act aggressively and will need only an advanced handler to deal with them.
In other situations it is also important to build trust. However don't let your horse learn that it can escape whatever you are doing by kicking out. Some horses will avoid you touching their legs by kicking out. If you think that your horse is doing that try to stay safe but also don't give in. Sometimes horses pick up their legs as though to kick and most handlers immediately let go. If the horse isn't being aggressive then don't release the leg, hold on until they put their leg back down.
What not to do
Don't punish the horse for kicking out, unless you are sure that your horse is just doing so as an escape from something. Often kicking is a way of showing that the horse feels threatened and punishment will only make that worse. Don't put yourself in a dangerous situation. If you don't feel comfortable with the situation get help.