If the court finds that the defendant has a lien on the property but that the defendant is not otherwise entitled to possession of the property, judgment shall be rendered for the defendant for the amount due under the contract, together with, or deducting, costs as determined by the following section. Upon payment of this amount to the defendant the bond provided for in the preceding section shall be held satisfied, and shall be delivered up to the plaintiff.
Mass. Gen. Laws ch. 255, § 38