If, at the final hearing, the court finds that the defendant is mentally ill and as a consequence of such mental illness poses a real and present threat of substantial harm to himself or to others, the court shall order the defendant committed to the custody of the Commissioner of the Alabama State Department of Mental Health or to such other public facility as the court may order.
If the court does not make such a finding, then the defendant shall be released from custody forthwith.