If the charges pending against a defendant are dismissed, the court that issued the order under Article 46B.0711, 46B.072, or 46B.073 shall send a copy of the order of dismissal to the sheriff of the county in which the court is located and to the head of the facility, the provider of the jail-based competency restoration program, or the provider of the outpatient competency restoration program, as appropriate. On receipt of the copy of the order, the facility or program shall discharge the defendant into the care of the sheriff or sheriff's deputy for transportation in the manner described by Article 46B.082.
Tex. Code Crim. Proc. § 46B.078