No, the Court would not just casually acquit the Accused if he has mental disorder.
The Court would conduct investigations on his mental condition and without any ambiguity upon medically confirmed that the Accused has incurable mental unsoundness it would then acquit him from the case.
Otherwise, the case will be kept under abeyance till the Accused was cured for his mental ailment and return to face the Trial.