If the defendant recovers judgment against the plaintiff, all the proceeds of sales and money collected by the sheriff and deposited with the clerk and all the property attached and retained by the sheriff shall be delivered to the defendant or the defendant's agent. The order of attachment shall be discharged and the property released therefrom.