The term 'running around like a headless chicken' has its origins in what many farmers know - chooks can indeed continue to run about after their heads are chopped off.
It is commonly believed that headless chickens run because many of the birds' reflex movements are controlled by their brain stems, not their brains - meaning a chicken will sometimes continue to race about.