If the court having jurisdiction of a case under sections fifteen to eighteen, inclusive, becomes satisfied that the alleged father and the mother have married each other and the child has become or will be the legitimate child of the alleged father or that it is for the best interest of the child, the case may be dismissed and if the court certifies that it is for the best interests of the child, no further prosecution shall be maintained under any of said sections.
Mass. Gen. Laws ch. 273, § 17