Claims of insanity, mental health problems, stupidity, or disabilities are completely invalid reasons, in my view, for someone not to stand trial.
If someone has committed a crime, it does not matter what their mental state is so long as they are conscious, unless they have some sort of temporary health issue (say a traumatic brain injury) where they will be expected to be able to better defend themselves in the short-term future, in which case the trial should simply be postponed.
Take, for example, these two little demons who completely randomly decided to just runover an old man riding a bike. The driver (19) who killed him was just found “unfit for trial”. He was moved to a psychiatric facility, and his charges were suspended.
People should not be able to dodge charges, even temporarily, just by acting or even being mentally unwell, in my view.