For the police tasked with capturing suspected killer Mohammed Merah, the basic goal was to keep him contained, talking and off-balance.
But even though sieges are fundamentally straightforward, and specially-trained police prepare exhaustively, there are so many variables that the best-laid plans can go awry in an instant.
Sometimes the only victim is police reputation. There was a torrent of criticism in Newfoundland when a suspect slipped through the police cordon after they tried to flood him out in 2010. Leo Crockwell surfaced in a nearby village and nobody was hurt.
The stakes were much higher in Toulouse, though, where a 32-hour siege came to a violent end Thursday. Mr. Merah, the suspect in seven killings, died after police poured into his apartment, sparking a hail of gunfire.
The basic siege goal of getting him out alive without putting police at undue risk, the stated desire of several leading French politicians, proved an impossible task.
Long before the eyes of the world were on the nondescript low-rise in Toulouse, police had taken up quiet positions around the building. They reportedly did not remove other residents from their apartments, presumably because it would be impossible to do so without alerting the suspect. But initial attempts to arrest Mr. Merah failed and several officers were wounded by gunfire.
Retreating, the surrounding officers settled into waiting mode.
With hundreds of police on the scene there was no realistic prospect of escape. But Mr. Merah was believed to have several automatic weapons and police had to allow for the possibility that the suspect, reportedly steeped in jihadist propaganda, could have stockpiled explosives as well.
Police soon made contact with Mr. Merah and provided him a phone or walkie-talkie in return for one of his weapons. Talks began. The substance of several of the exchanges was relayed to the media and the suspect seems to have been keen to explain his motives. This not only implicated him in this month's killings, but also would have allowed police to begin building a psychological portrait of their target.
In tandem with the negotiations were attempts to keep Mr. Merah unsettled. Several times police blew holes in the walls of the building, providing access points and likely putting the suspect on edge.
As night fell, police cut the building's electricity and gas connection.
There was a long silence overnight from within the apartment. A government minister told reporters that there had been "no contact, no showing from him" in spite of efforts through the night to talk to Mr. Merah.
A police source told Reuters that night-vision goggles showed no movement. When video cameras were sent into the apartment they revealed no sign of life.
There are reports that gas was introduced into the apartment in an effort to subdue the suspect, should he still be alive. But when heavily armed police threw in stun-grenades and poured through the apartments door and windows, Mr. Merah reportedly burst out of the bathroom.
Footage from a television camera nearby indicates a fusillade. The crack of individual shots was quickly replaced by sustained bursts of gunfire. It was not immediately clear how much of the firing was by police but the French authorities said Mr. Merah was wielding two guns, one of them a mini-Uzi.
About 300 rounds were fired in total, the French said.
Mr. Merah died moments later after tumbling from the bathroom window, still firing.