re
As I understand it from the books, the Nazgul fled because they felt they had accomplished their mission after the Witchking stabbed Frodo. The piece of the knife that broke off was slowly turning Frodo into a wraith that would eventually do the bidding of the Witchking. There was no reason to press the fight, so they pulled back after Frodo said the name of Elbereth and removed the ring. That name also is apparently a bane to the Nazgul as well as the fire. I would say it was a combination of the fire, the name of Elbereth, and the Witchking thinking the knife would do the work of finishing Frodo and recovering the ring without having to risk disembodiment.
If not for the help of the elflord Glorfindel, his swift horse, and Elrond's and Gandalf's magic, he would have been right.