If, upon the foreclosure of any mortgage and the sale of the premises therein described, there shall be paid into court moneys representing an estate in dower or for life or for years, or an estate by the curtesy in such premises or any part thereof, any person entitled to such estate may make application to the court for a sum in gross in lieu thereof, and the court shall direct the payment of such sum in gross out of the proceeds of the sale of the premises to the person entitled to such estate, as shall be deemed a just and reasonable satisfaction for such estate, and which the person so entitled shall consent in writing to accept in lieu thereof.
If no such consent shall be given before the distribution of the proceeds of the sale, the court shall ascertain and determine what proportion of such proceeds will be a just and reasonable sum to be invested for the benefit of the person entitled to such estate, and shall order the same deposited with the court and under the direction and control of the court for the benefit of the parties entitled, the interest thereon to be paid to the parties entitled as the same may become due as compensation for and in lieu of such estate. At the termination of such estate the principal sum shall be paid to or distributed among the parties entitled thereto.
N.J.S. § 2A:50-34