Its just the central nervous system shutting down. The heart actually runs on its own set of nerves and blood supply from the brain too. I went to college for large animal vet medicine quite a few years ago. This was back before the animal rights people stepped in and won't let the students do alot of things anymore.
I remember when the head of the vet science department took us through a necropsy of a horse. They walked it in, gave it a bolt to the head, and split it in half right before us. The blood was flowing everywhere! A girl fainted behind me. I specifically remember the instructor saying that the heart will keep on beating for up to an hour after the animal is 'dead'.
We also did experiments with alot of live frogs back then too. We would pin them down and stick another pin in their brain and wiggle it around to technically have them brain dead. When we cut them upen, the hearts were still going. There were chemicals we would inject to their hearts to speed up or slow down the beating. There was also a chemical (I think its used in putting animals to sleep)...some sort of potassium solution... that would stop the heart immediately if even one drop came in contact with it.
My friends call all that moving around the "Crappie Flop"...kind of like the fish out of water. I guess this really doesn't bother me anymore. If I do have to put something out of its misery now, at least I know the job is done then if I see that.
Btw.... This was about 10-15 years ago when I went out to SDSU. I'm sure alot of policies on animal rights have changed since then.
Amy