My mom's side of the family got together one long weekend at our cabin when I was about eleven. At the time, we had a miniature dachshund named Tessa who often got loose. I remember standing in the neighboring property yelling her name, trying to get her to come to me. When she finally came and I hooked the leash onto her collar, I scolded her for having run away. "Bad dog!"
My Uncle Norm stood near and said, "Here, this is what you do. When she comes back you say, 'good dog!' and show her you're happy with her. That way she knows returning to you is the right thing."
Uncle Norm is awesome.