It wasn’t a well-studied policy statement, but President Trump wasn’t wrong when he told reporters that closing mental asylums en masse in the 1960s went too far — and that a humane society needs institutions to shelter and care for those who are instead populating our streets.

“If you look at the ’60s and ’70s, so many of these institutions were closed,” the president said last weekend. “And the people were just allowed to go onto the streets. And that was a terrible thing for our country. … But a lot of our conversation has to do with the fact that we have to open up institutions. We can’t let these people be on the streets.”

There was, indeed, a time when that was well understood. By the 19th century, there was a nationwide system of asylums that ensured a place for those who couldn’t care for themselves and whose families couldn’t care for them.

By 1940, 450,000 patients were institutionalized in public mental hospitals nationwide. Though the care given to the mentally ill was far from perfect, it aspired to be therapeutic — albeit lacking the antipsychotic medications so crucial today in treating schizophrenics, such as my great-uncle, or manic-depressives, who then as now constituted the other major group of the severely disturbed.

Yet beginning in the 1960s, horror stories from the most poorly run asylums became fodder for a liberal movement that asserted that mental illness was a “myth,” setting the stage for the massive de-institutionalization drive that has left too many of the troubled to fend for themselves. The federal government has played a role, limiting the use of Medicaid funds for those housed in large institutions.

By early 2016, writes psychiatrist E. Fuller Torrey of the Treatment Advocacy Center, “states had eliminated more than 96 percent of the last-resort beds that existed in the mid-1950s; after a brief period of expansion in the 1990s, private hospitals, too, are shrinking their psychiatric inpatient capacity.”

In 1955, Torrey points out, 560,000 patients resided in state psychiatric facilities; by 2015, the number had fallen to 45,000. As my Manhattan Institute colleague Stephen Eide has noted, Gov. Andrew Cuomo continues to call for closing “unnecessary” beds in psychiatric centers and reinvesting those funds in community services.

There is no doubt that many of those suffering from mental illness can be helped in such settings, including through supportive housing, which combines assistance with a residence. Such assistance must, what’s more, aim to help those who might otherwise need institutional care — the most deeply disturbed, in other words. Law enforcement has a key role in diminishing street homelessness, as well.

“Re-institutionalization” is far from the only answer — and is unlikely to ensure that potential mass shooters will be identified and deterred. Still, numbers matter. In the 1950s, when mental health care in New York was almost exclusively an inpatient matter, patients in state facilities numbered 93,000. The census is now down to below 3,000. The magnitude of that change cannot help but have had something to do with what we are seeing on the streets.

Even were there more beds, in New York, state law makes involuntary commitment especially hard, requiring a difficult three-part test: being a danger to oneself and others, certification that hospital treatment is essential and an inability to understand one’s need for care and treatment. Memo to Cuomo, who said the president “didn’t know what he was talking about”: Gun control isn’t the only way to deal with the minority of the mentally ill who may be prone to violence.

The feds have a role to play, too. The president should ask his own Department of Health and Human Services to eliminate the long-standing prohibition against the use of Medicaid funds to help support those in “institutions for mental disease.” During the Trump administration, the Substance Abuse and Mental Health Services Administration has made clear that it’s open to waivers of the rule but has yet to grant one.

A larger system to care for the deeply troubled should be part of a compassionate policy.

Howard Husock is the vice president of research and publications at the Manhattan Institute.