If the proceedings before the magistrate are brought before a district court and quashed, or judgment is given against the plaintiff, the district or other court in which final judgment is given shall, if necessary, restore the defendant to the possession, and issue such writs as are proper for that purpose.
N.C. Gen. Stat. § 42-35