Most mass shooters are not clinically "mentally ill." On the other hand, most mentally ill people are not murderers. Therefore, blaming mass shootings on mental illness is really a straw argument. Even if we locked up every "mentally ill" person (which in itself would be a gross human rights violation), there would still be mass shootings.
I agree that the other things that you mention don't work, either. What are left are two things: (1) we come to accept that a certain amount of gun violence is endemic and unavoidable, and/or (2) we arm everybody, so that if anyone gets out of line, they are gunned down immediately.
This is a sad commentary on where we are as a society.
Repeated events in the past few decades have shown that the majority of criminals who take part in mass shootings are mentally ill and they have a file thicker than a Hi-Point's slide chronicling such a repeated pattern of insanity. The Parkland Shooter had over thirty points of contact with law enforcement for being nuts. Yet he was swept under the rug. As have others, constantly.
As for the Lewiston ME shooter.
In July 2023, service members who were training alongside the Lewiston, ME shooter at West Point reported that he was behaving erratically and requested that law enforcement intervene. The shooter had complained of hearing voices and threatened to "shoot up" a military base in Saco. The New York State Police responded to the report and transported him to the Keller Army Community Hospital at the academy, where he was committed for two weeks for medical evaluation. That qualifies in my opinion as a reason to keep him off the streets. Dude wanted to shoot up a military location because the voices told him to. He had LE called on him because of his actions. That's a good reason to keep someone off the streets. This wasn't a few years ago where he got better afterwards, oh no, this was three months ago when he spent two-weeks in the looney bin.
As a former LEO, I can tell you from over a decade's worth of personal experience. Crazy people shouldn't be on the streets. The closures of mental health facilities by Jimmy Carter and Ronald Reagan was a horrible idea. These facilities need funding, right now, and people who are mentally ill need to get treatment and/or need to be kept off the streets. But since, society refuses to fund mental health treatment and the lawmakers have decided to cast them on the streets. Becuase the majority of the homeless are mentally ill who can't function in society. It is a problem that is just going to get worse and worse.
They have become a law enforcement problem and the way LE deals with the mentally ill is by arresting them for crimes. But everyone constantly calls on LE to be a damn counselor.
Are all mentally ill people criminals and murderers? Nope. But a good chunk of criminals and murderers are mentally ill. Furthermore, if you're going around openly telling people the voices want you to shoot and kill people, you shouldn't be on the streets.
Sorry, it doesn't work both ways.
Gun control has been proven to be an abject failure and so has letting the mentally ill loose on our streets.