When an animal is killed in an abattoir, it is first stunned, either by captive bolt or by an electrical stun gun. This knocks the animal out - it's unconscious so it doesn't feel anything.
Animals can recover from a stun gun, and also from a captive bolt, especially if it is the type that doesn't penetrate the skull, so regulations require that animals must be bled out rapidly after being stunned.
Quite often there will be muscular contractions after the animal is dead - as Rabelais says, these are post mortem spasms, and unless you are expecting them, it can be quite distressing as it appears that the animal is alive when in reality it isn't. There can also be spasms after the animal is stunned due to abnormal brain activity - again, this isn't the animal consciously struggling.
There are many reasons that chemicals aren't used in slaughterhouses:
- the drug remains in the body after the animal dies and contaminates the carcass, making it dangerous to eat. Doses used to kill a large animal are also lethal in humans!
- It would take too long to find a vein and inject every animal
- The cost of the drug would also make it too expensive
- There is still a risk of using the incorrect dose that won't kill the animal, and the drug causes pain at the injection site.
The methods used aren't 100% fallible, and with the huge numbers of animals going through the abattoirs every day some animals aren't stunned properly. However it is the priority of everyone working in these places that all animals are treated humanely. Here in the UK we have some of the toughest Animal Health and Welfare regulations in the world.
You can view the regulations here:
http://www.opsi.gov.uk/si/si1995/Uksi_19950731 _en_1.htm
And the DEFRA website has more information: