Preying mantises (there are several species in North America) are obviously very specialized for predatory existence. They have large eyes, sharp and pointed mandibles, and front legs highly modified for capturing and holding prey. They are also cryptically colored (to hide from prey as well as from predators) and have a stick-like body shape. Their movements are typically slow and deliberate, and they are capable of stalking small and active prey like flies.
Female preying mantises are reputed to practice what is called in the literature "sexual cannibalism". Because they are predators, they are programmed to respond to other insects in the environment as potential prey. This includes males of their own species, which in many cases are smaller than the females. Male preying mantises approach their females with considerable caution (I am being anthropomorphic). As males approach females they do a variety of displays that are designed to signal to the female that they are males of the species are would like to mate. When a male gets close enough to a female, he mounts her and begins to do copulatory attempt motions, in which he bends the tip of his abdomen around and under the female's abdomen. This motion is stereotyped (always done the same way) and innate (doesn't have to be learned). Males that succeed in copulating with a female typically flee quickly once copulation is complete, because a female will try to catch and eat her mate.
Sometimes females will try to catch and eat their mate before or during copulation. If a female can do so, she will reach around and bite a male's head off while he is copulating. If this happens, the male's decapitated body continues copulating, and eventually will succeed in inseminating the female, even while she is consuming his body. The adaptive significance of this ability should be obvious. Any male that could successfully inseminate a female while becoming her meal would leave more progeny than a male would could not do this.
What about a male who has mounted a female, but has not started copulating?
If the male loses his head at this point in the relationship he will continue
to do the copulatory attempt motions, and in fact does them more vigorously
and longer than a male that is intact. These males may succeed in copulating
with the female, and again may inseminate her even while she is consuming
him. The mechanism that is responsible for this strange behavior has been
elucidated. In the brain of the male preying mantis is a ganglion that
acts to inhibit the copulatory motion. In the thorax, there is another
ganglion that stimulates the copulatory motion. When the male is decapitated,
the brain ganglion and its inhibition is removed, and the thoracic ganglion
and its stimulation takes over, resulting in prolonged and vigorous copulatory
attempts. The selective advantage of this ability should also be obvious.