(2) The Director or person in charge, as the case may be, shall detain the person according to the terms of the warrant or order mentioned in subsection (1), and shall cause the person to be delivered to such court, justice of the peace, coroner or other public officer lawfully exercising civil or criminal jurisdiction, or shall discharge the person at the time named in and according to the terms of such warrant or order.