The story
From the wartime practice of welding a metal spike into the touch hole of a cannon (generally done to enemy guns by raiders, or to one's own guns if forced to abandon them in a retreat), making the cannon impossible to fire.
Etymology from Wiktionary, CC BY-SA 4.0.