Not necessarily. It depends somewhat on the jurisdiction, but it is typically very difficult to win a not guilty by reason of insanity defense. Many people who have significant mental problems are still found guilty of crimes (see link below to npr article discussing requirements for an insanity defense).
Also, it is actually more of a "get out of jail free and locked up in a psychiatric institution until it's proven that you are no longer a danger" card. There have been cases in which a person was found not guilty by reason of insanity and ended up spending a longer period of time in a mental hospital than they would have if they had simply pleaded guilty (at least that's what one of my professors said in law school, but I have not tried to find a documented case in which this actually happened)(I mention this an item of interest, it's highly unlikely that a mass murderer would be worse off with a successful insanity defense).
A famous example of an insanity case is John Hinckley. He was released from a psychiatric institution in 2016 after about 35 years (he attempted to assassinate Reagan in 1981). I'm not sure what his total prison time would have been if he had been convicted on all counts (I suspect it would have been longer).
Here's an article about the John Hinckley case and the effect it had on the insanity defense:
>>>Decades later, the chances of winning an insanity defense are punishingly slim, according to lawyers and psychiatrists, especially for crimes like homicide.<<<
John Hinckley's not-guilty verdict prompted tighter restrictions on the insanity defense. Civil rights advocates say that means seriously ill people are imprisoned without adequate treatment.
www.npr.org