§ 1347. Motion for cancellation of notice of pendency. 1. Mandatory cancellation. The court, upon motion of any person aggrieved and upon such notice as it may require, shall direct any county clerk to cancel a notice of pendency, if service of a summons has not been completed within the time limited by section one thousand three hundred forty-five of this article; or if the action has been settled, discontinued or abated; or if the time to appeal from a final judgment against the claiming authority has expired. 2. Discretionary cancellation. The court, upon a motion of any person aggrieved and upon such notice as it may require, may direct any county clerk to cancel a notice of pendency, if the claiming authority has not commenced or prosecuted the action in good faith. 3. Costs and expenses. The court, in an order canceling a notice of pendency under this section, may direct the claiming authority to pay any costs and expenses occasioned by the filing and cancellation, in addition to any costs of the action. In order to establish the claiming authority's liability for such costs and expenses, the person seeking such costs and expenses must prove by a preponderance of the evidence that, in causing the notice to pendency to be filed, the claiming authority acted without reasonable cause and not in good faith. 4. Cancellation by stipulation. At any time prior to entry of judgment, a notice of pendency shall be cancelled by the county clerk without an order, on the filing with him or her of: (a) An affidavit by the claiming authority showing which defendants have been served with process, which defendants are in default in appearing or answering, and which defendants have appeared or answered and by whom; and (b) A stipulation consenting to the cancellation, signed by the claiming authority and by the attorneys for all the defendants who have appeared or answered including those who have waived all notices, and executed and acknowledged, in the form required to entitle a deed to be recorded, by the defendants who have been served with process and have not appeared but whose time to do so has not expired, and by any defendants who have appeared in person. 5. Cancellation by a claiming authority. At any time prior to the entry of a judgment a notice of pendency of action shall be cancelled by the county clerk without an order on the filing with him or her of an affidavit by the claiming authority showing that there have been no appearances and that the time to appear has expired for all parties.