We used to confine people like this in a psychiatric hospital for treatment and evaluation. Thanks to Reagan emptying out the mental hospitals in 1984 by drastically cutting Federal funding (after he did the same in California), and working to weaken or abolish involuntary confinement laws, we've never recovered the ability to take people with questionable mental stability off the streets. 

While there was some abuse of the involuntary confinement laws, and the cost of keeping so many people out of the general population was high, I believe it did prevent many potentially dangerous people from committing crimes. 

Now its all "adjust the meds" and let them run off to do whatever. And eventually toss them into very expensive prisons where they get little or no treatment once they finallly do harm another citizen. Too late. And probably doesn't actually save money in the end. 

Those who go into prison with mental issues, and serve their time, rarely emerge with their problems solved.