What works best for you will depend in your set-up, climate and time of year, but I generally start at 5 weeks. A big issue is predators, not so much whether they can find their way into the coop at night. The small birds can be pretty vulnerable.
If they can find their way from the run into the coop at night they should want to return to the coop. One problem I have had when they start ranging is that they do not handle the concept of "gate" well. Even if they have been going through a gate all day when it starts to get dark they get in a panic to return to their coop. If they happen to be on the wrong side of the run fencing they get all kinds of upset, pacing back and forth and trying to get through the fence. They totally forget that a gate is 15 feet away. The first couple of nights after I let them out I make sure I'm down there to help them if they need help, whether they are 5 weeks old or five months old. After a couple of nights they catch on.
I've had a broody hen wean her chicks at three weeks a couple of times. Both times those three week old chicks returned to where they were used to sleeping without Mama's help. It's not so much age but possibly other considerations.