This is a great question, but I don't have a complete answer for you. I do want to say that you are certainly correct in your understanding. I'm currently going through insane asylum records in a late 19th century American institution, and it's surprising the incredible range of individuals that were admitted.
Many are clearly mentally ill, though they don't have a diagnosis like we do today. These people could be manic or melancholic (depressed); others were delusional. Most were violent and would attack hospital staff and family members. Some destroyed their rooms, including the bedding, and would tear up their clothing. Only a few were restrained. Many are listed as "very dangerous." One memorable record had the word BITER underlined several times.
However, the insane asylum was also home to other individuals who today we would be surprised to see there. Many epileptics resided at the asylum. These people had seizures so frequently and violently they could not be cared for by their family. Similarly, many people with strokes ended up in the asylum, in part because of their confusion and belligerence but also because it was difficult to tend to them. Furthermore, a good number of people clearly have untreated traumatic brain injuries; you can tell because the admission record usually says something like, "Was recently struck in the head by a branch," or "Fell on her head as a child." Their demeanor always changes after their injury. Some of these people, interestingly, are assumed to be epileptics.
There's also a category of people called "inebriates" that we today would know as alcoholics. These people are prone to excessive drinking - and were committed to the asylum because of it. Understand that in the 19th and even early 20th century, feelings for temperance were rampant, and being alcoholic was not only looked down upon, but it was seen as something that needed to be treated and taken care of for the sake of the individual, family, and society.
There are also a few very tragic cases of the very old being admitted to the insane asylum. These people range from 60 to 90 years old. They tend to be somewhat senile, and some have survived strokes. The admission record invariably remarks, "Does not have long to live."
As for the intellectually developmentally disabled, there are several cases of "idiots" that I have seen at the asylum. Many of these people were found wandering the streets of cities across the state and brought by authorities to the asylum. They have no real background history to report on, and often stay there until they die. Some are very young, about 19 to 23 years old, but clearly have reached an age where their family can no longer tend to them, so they were committed. Most seem to stay in the asylum until they die. They were then buried in unmarked graves by the institution.
In short, the mentally ill and other medically difficult cases were often placed in institutions in the late 19th century. The system itself was not intended as a place only to treat individuals and release them back into the public, although many did "improve" and were "restored" (using common terminology). Instead, the asylum was a place where those who could not be cared for at home and needed more expert care had to be sent. Some of these individuals, including the intellectually disabled, would remain in the asylum for 25+ years until their death.
Although I can't exactly answer your question, I can assure you that the shift that you are looking for did not happen in the 19th century and must have occurred sometime in the 20th century. I would love to know if there is a more precise date/time for this, but I only know my own time period, unfortunately.