by using water will it cause fire?
You will generate hydrogen gas whatever you use, which is flammable, but unless you do it next to a naked flame or a powdered metal you should not get a fire.
If you quench with water you generate NaOH which may hydrolyse your ester.
Can you give more info on the reaction?
I assume the transesterification is:
RCOOR' + R''OH + NaH ---> RCOOR'' + R'ONa + H
2If this is correct and R''OH in excess then there is no NaH left. If NaH is in excess, quench with R''OH would be my advice. If it is an intramolecular transesterification (lactonisation), or R''OH is too precious to be used in excess, then I'd suggest either a bulky alcohol (like t-BuOH) or a weak acid (like AcOH) at 0
oC. I would avoid adding water if the mixture is strongly basic (or strongly acidic) as you risk hydrolysis of the ester.