I had gone through that phase and broke my chickens of doing that by conditioning them. While they are in the nest box, I open and close the lid to the nest box to condition them that I will be getting in and out of their nest. I also conditioned them not to roost on the entrance to the nest box by placing a spiky plastic thing that screws in. This keeps them from roosting in the wrong spot. I have also conditioned my birds from a juvenile age, that I will be in and out of their chicken yard to give them food and water. We also have a roosting bar all across the back wall of the coop for them to sleep on. They don't sleep in the nest box anymore for me, and anytime I come out to see them they meet me at the chicken run gate. Hope this helps.