The story
From the image of an axe head becoming loose and suddenly flying free of its handle, a vivid metaphor for losing control. The phrase is an early 19th-century American idiom, with printed examples first appearing c. the 1810s–1830s.
Etymology from Wiktionary, CC BY-SA 4.0.