We don't really know how fast a balrog can run, how far away the exit is, or if it is small enough to block the Balrog. And there would still be the matter of the orcs chasing them as well.
The bridge of Khazad-dûm was intentionally designed narrow, to stall an invading army. If anything, the narrow bridge itself ought to be an obstacle. It might very well have been Gandalf's improvised plan to lure the Balrog onto the bridge and collapse it, since he was successful in doing exactly that - or it would have been a successful plan if the Balrog hadn't caught him with the whip.
But Gandalf's priority here it to get the rest of the Fellowship and the Ring away to safety, so he draws the Balrog's attention on purpose to buy the others time, possibly even revealing that he is a Maia - the "Flame of Anor" part is a bit mysterious.
Gandalf might very well have decided to take the fight despite the uncertain odds, just to ensure that Frodo got away safely. This could explain why he doesn't want the rest of the party to engage it either. He claims that "this foe is beyond any of you" - it could be true, but he could also just be saying that to ensure that the others stay with Frodo.
The out-of-universe explanation for the scene is simply that this scene is the climax of the whole Moria episode. If the Fellowship had just legged it, it wouldn't be nearly as dramatic. (The endless "Why didn't they just fly an eagle to Mt Doom?" discussion - because it wouldn't have been much of a story then, would it?)
Tolkien had skilfully been building up an ominous feeling from the point where the Fellowship is trapped at the western gate, through the journey through the dark, the discovery that Gollum is stalking them, then the escalating events in the Chamber of Mazarbul, all leading up to the fight with the Balrog.
And the first time you read the book/see the movie, you actually don't realize that Gandalf...
survived. Or rather got reincarnated.
Gandalf falling to his death sets the mood for many chapters ahead.
The Moria chapters are perhaps, in my personal opinion, some of the most well-written in the whole story. Tolkien's writing style was very much about slowly building up the thrill and tension during several chapters, more and more intense until it ends with a dramatic final event. This is then followed by a more relaxed chapter to give the reader some room to relax before starting the next story arc. Both The Hobbit and LotR are written exactly in this manner.