If, before levying under a writ of attachment or execution, a sheriff receives notice that the defendant has become a debtor in a bankruptcy case, the sheriff shall immediately give written notice of that fact to the plaintiff's attorney of record, if any, otherwise to the plaintiff, and shall not be bound to levy under the writ. If, after levying on property under a writ of attachment or execution, a sheriff receives such notice, the sheriff shall give written notice of the attachment or execution, describing the property seized, to the trustee in the bankruptcy case if there is one, otherwise to the bankruptcy court, with a copy to the plaintiff's attorney of record, if any, otherwise to the plaintiff, and shall transfer the property to the trustee on demand or as the bankruptcy court otherwise directs. If no demand is made on the sheriff for surrender of the property and the sheriff thereafter receives notice of the closing of the bankruptcy case, the sheriff shall give written notice by first-class mail to the plaintiff's attorney of record, if any, otherwise to the plaintiff, requiring that the plaintiff release the property or obtain a renewal of the writ from the court, and, if the plaintiff fails to release the property or to apply for a renewal within fourteen days after the mailing of the sheriff's notice, the sheriff shall release the property to the defendant.