§ 6514. Motion for cancellation of notice of pendency. (a) 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 6512; or if the action has been settled, discontinued or abated; or if the time to appeal from a final judgment against the plaintiff has expired; or if enforcement of a final judgment against the plaintiff has not been stayed pursuant to section 5519. (b) Discretionary cancellation. The court, upon 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 plaintiff has not commenced or prosecuted the action in good faith. (c) Costs and expenses. The court, in an order cancelling a notice of pendency under this section, may direct the plaintiff to pay any costs and expenses occasioned by the filing and cancellation, in addition to any costs of the action. (d) 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 of 1. an affidavit by the attorney for the plaintiff 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 2. a stipulation consenting to the cancellation, signed by the attorney for the plaintiff 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. (e) Cancellation by plaintiff. At any time prior to the entry of judgment a notice of pendency of action shall be cancelled by the county clerk without an order, on the filing with him of an affidavit by the attorney for the plaintiff showing that there have been no appearances and that the time to appear has expired for all parties.