josette's ghost had been visiting 'magtoria' since childhood. it is the reason her parents had her sent to windcliff in the first place. since they could not see josette they thought 'magtoria' disturbed and put her away...
seems like something of an overreach(permanently institutionalizing a child and in a padded isolation cell no less)but that's what the good mr. and mrs. evans decided was best.
I don't know if the padded cell and shock treatments (
) were so much her parents ideas as they were the hospital's decisions. And I could be wrong, but I wouldn't think anyone could be committed without a doctor's say so, so chances are her parents had Maggie examined and it was decided by the doctor or mutually between the doctor and her parents that she should be committed.
But as for the extremeness of the padded cell and the shock treatments, sadly it seems such practices were certainly in existence in the '50s and '60s, and even beyond. There were broad sweeping investigations of many institutions where such practices and those much worse took place with the end result being that such places were shut down for ineffective treatment and excessive cruelty. The film is probably strongly implying that Windcliff was such a place.