It means to become so angry you lose control of yourself.
The literal image is of the head of an axe or a hammer. Traditionally, the metal head is fastened to a wooden handle by a tight friction fit. Through use, the head can loosen. When you swing the axe the head "flies off the handle" and goes flying freely through the air, dangerously.
An interesting modern parallel is "to go ballistic." There are "ballistic missiles" and "guided missiles." A guided missile is under control and can be steered as it flies. A "ballistic missile" is not guided. Like a cannonball, it flies freely in whatever direction it was started. If a guided missile malfunctions, control is lost, and it careens through the air in whatever direction it was last going in. It is thus like the head of an axe or hammer that has "flown off the handle."