Depends on the circumstances. It's usually an affirmative plea, but it's theoretically possible to argue for certain crimes that a specific form of insanity makes it impossible to commit a specific crime. Mostly we're talking about crimes where the reasoning behind the crime is more important than the action of the crime in that case.
That said, winning on a criminal insanity plea carries with it the inherent risk that even if you aren't going to end up in a prison, the judge is going to assign you to a mental health program whether you like it or not, and most likely in a closed institution. It's entirely possible to plea insanity for a crime with a relatively short sentence (say robbery) that would normally result in a few years in prison, and then win on that plea and be confined to a mental health institute for decades before you're released because the staff is satisfied you are no longer a risk to the general public. And that's if you are ever released.
As for the USA justice and correctional system... It's working exactly as intended from what I can see.
That said, winning on a criminal insanity plea carries with it the inherent risk that even if you aren't going to end up in a prison, the judge is going to assign you to a mental health program whether you like it or not, and most likely in a closed institution. It's entirely possible to plea insanity for a crime with a relatively short sentence (say robbery) that would normally result in a few years in prison, and then win on that plea and be confined to a mental health institute for decades before you're released because the staff is satisfied you are no longer a risk to the general public. And that's if you are ever released.
As for the USA justice and correctional system... It's working exactly as intended from what I can see.