loose cannon (n.)

in the figurative sense "wildly irresponsible person, potent person or thing freed from usual restraint," by 1896; in the literal sense an object of dread on old warships; the figurative use probably arose from a celebrated scene in a popular late novel by Victor Hugo:
You can reason with a bull dog, astonish a bull, fascinate a boa, frighten a tiger, soften a lion; no resource with such a monster as a loose cannon. You cannot kill it, it is dead; and at the same time it lives. It lives with a sinister life which comes from the infinite. It is moved by the ship, which is moved by the sea, which is moved by the wind. This exterminator is a plaything. [Victor Hugo, "Ninety Three," 1874]