It isn't so much about a particular age as it is reaching the understanding of the routine. Chicks raised by a broody hen would have this concept taught from the first day she took them outside as, at roost time, she would lead them back into the coop for the night --- chicks brooded artificially don't have this so you become the mother hen and, as you have seen, you get the task of teaching them the routine. The good news is that it usually doesn't take too many repetitions for them to get the idea.
One thing that can help is to make the inside of the coop lighter than the outside - if you think about it, coops are generally fairly dark inside as night starts to fall as the light goes out of them first - young birds are drawn to stay outside, clinigning to the last bits of light, and by the time they realize what is going on its completely black inside and that does not appeal to them at all -- a simple small light inside the coop for a few evenings can help to draw them in as dusk falls. An alternative to pushing them in is to call them in -- have you conditioned them to associate a nice treat with a call? If so, just call them from within the coop (if not a walk in coop you can simply open whatever hatch there is and call from there so that it comes from inside).