If an action or proceeding to establish a lien upon such premises terminates otherwise than in a judgment establishing such a lien, or if the judgment be fully paid, such notice of pendency of action or proceeding may be cancelled. Prior to the termination of such action or proceeding the notice may be cancelled by giving an undertaking.
N.Y. Mult. Dwell. Law § 360