During the Siege of Almeida in 1810, the Portuguese garrison stored their gunpowder in the castle's magazine, which worked out fine until a freak hit from a French explosive shell in the courtyard ignited a trail of spilled gunpowder from leaky barrels and detonated the entire magazine and killing 600 defenders.
(Sir Charles Oman, A History of the Peninsular War, Volume III)
The events are also fictionalised in Bernard Cornwell's Sharpe's Gold novel, in which Sharpe is forced to destroy the magazine.