Keeping your dog from running away might require a mix of training, money spent on a fence and potentially even surgery. Because the impulse to run away or escape is different for each dog, it's important that you understand what's causing your dog to want to take off so you can then address the problem head on.
Perhaps the easiest way to prevent your dog from escaping your yard and running away is to install traditional fencing. How tall your fence needs to be depends on how big your dogs are and their climbing abilities. For example, a 4-foot fence might be enough to keep most small dogs confined to your yard. If you have a fence that provides "footholds" -- such as a wire fence or a fence will horizontal slats -- your dog might be able to climb. To prevent this, you will either need a taller fence or one with a smooth surface so Fido can't climb up. If you have a dog who likes to dig, you'll need to bury the fence to prevent him from going under it. Six inches should suffice in most cases.
Invisible fences work by sending a short and mild electric shock to your dog's collar when he tries to cross over the perimeter marked by the fence. Many collars also have some sort of beeping sound or ultrasonic tone that will let your dog know he's approaching the line. This sound is meant to help your dog stop and avoid the shock. Training a dog to understand an electronic fence can take some time and some owners might object to the idea of shocking their dogs just to keep them from running away. Also, keep in mind that forgetting to change the battery or interference from other electronic devices could render the fence less effective and allow your dog to escape anyway.
Training To Change Behavior
Teaching your dog the "Come" command might help you keep more control over him. For this to work, however, you need to start training in a small, controlled environment, where he can't easily get distracted by noises, other animals or people. Practice the "Come" command in your own yard, rewarding him with playtime, a treat or lots of praise when he does come. You can later move the practice over to the dog park or other places where distractions are present.
Other Things You Can Do
Dogs run away for many reasons; sometimes eliminating that reason will stop the behavior. For example, unaltered dogs might escape to try to find a mate, especially in the case of males who can smell a female in heat. Spaying and neutering your dogs will take away this urge. Dogs might run away if they get scared by loud noises, because they feel lonely or simply because they are bored and need something to do. Make sure you make your dog part of the family rather than leaving him outside or alone for long periods of time.