The idiom is a moral story - it means that if you are going into a risky situation, be sure not to destroy any escape route.
It comes from the strategy of commanders of ancient armies.
The army crossed a river into enemy territory (by bridge or boats), and then the general commanded that the bridges or boats be destroyed. The army, with no way to retreat, had to fight or die.