The correct answer is modulation of descending motor pathways by brainstem and cortex
In simple terms, what happens is that your skin receptors send a message to your spinal cord describing the situation and your body reacts on its own to protect you. It's not voluntary action like most of situations involving pain aren't. Similar would be if you cut yourself or get bitten by an animal.