When the run and attached coop are locked up for the night the flock is confined. The pop door between the run and coop is always open. I have another pop door on the run that is set on a timer to open at 8am- the flock can come and go as they please then.
My coop is attached to a predator proof run. Flock free ranges during the day but they are confined from evening 8pm until 8am- heaviest predator times. When confined the coop and run is very secure The interfacing pop door remains open 24/7; run pop door (to outside) is on a timer.