Like most here, my preference is about 5 months, give or take a month based on circumstances. I once weaned one at just over 3 months for transportation reasons, but now think that was not the best decision. I doubt I would do that again unless it was necessary for the sake of the mare.
I prefer to separate for a few hours to several hours a day to begin with, then move the mares out to a pasture separated by a lane where they can see and talk, but not reach through to nurse. That leaves the foals in familiar surroundings with their friends.