If what you mean by "mental", is mentally ill, then I think this is what the judge should do:
If the person is found legally insane and has killed someone, this person isn't safe to be in society. But, they shouldn't be kept in prison, as they are ill. They should be kept in a mental hospital and rehabilitation must be attempted. If rehabilitation fails, they must remain in the hospital. If rehabilitation succeeds, they should be let back into society with caution.
This of course excludes bias in the system: many sane people who killed plead insanity to lower their punishment. Also, racial bias comes through. If y'all haven't noticed, when black people kill they are all thugs, when Arab people kill they are all Islamic terrorists, and when white people kill it's one mentally ill person.
This idea up there means that white people are more likely to get rehabilitation and ejected back into society than other races. It's dangerous, especially if the sane person was deemed insane in the first place.
Luckily (or unluckily), rehabilitation hardly ever occurs in our royally f**ked-up prison system anyway.