The mental institutions were closed, but they were largely replaced by group homes scattered around the general community, with insufficient supervision to protect either the residents (who are often victims of their government-paid caretakers in these homes) or the neighbors. These group homes may be cheaper to run than the mental hospitals were, but I believe serviceable mental hospitals could be run for what we’re currently paying for the group homes (most of which have had to fight local legal battles with people who don’t want the facility in their neighborhood, in order to get set up in the first place). The money is often coming from different line times in the federal and state budgets, but it’s still a lot of money. What used to fall in the “mental hospital” line item of government budgets is now found in additional expenditures via Section 8 housing subsidies, food stamps, Medicaid, “outreach programs”, and on and on.
There is no security. There are no gigantic orderlies with tasers. There are no needles or emergency meds, no restraints. No doctors or nurses. These are gentle, peaceful places.
I know you want a cheap solution, but it's not there. Ask any mental health professional. In the United States we use prisons to house the mentally ill -- the kind of crazies you are worried about. Otherwise, they are on the street, in our lives, until they commit a crime.
When you shrink government, you give up many protections. Arm yourself and your family. Be safe.