There was a very high profile case in Ontario over a decade ago. Basically, the man went into an absolute psychotic state on the travelling bus and cut the head off a stranger while everyone else on the bus ran for their lives. A decade later, he's been released- under a lot of conditions and on a lot of medication, but people are very upset that he'd ever be free at all. In interviews, he's a very interesting person…
It is interesting because different people and different countries seem to have different ideas about he purpose of the the justice system. Punishment/retribution, correction/rehabilitation, or protecting the public. Someone like this may not be guilty due to insanity, but still be a danger to the public for example.
Someone locked up for insanity wouldn't be released while they are still a danger to the public. But anyone imprisoned for a violent crime might be released while still a very clear danger to society, even murderers and similar. Time limited sentences work that way.