Obedience training — specifically, coming when called — is the best prevention for this problem. You should always walk your little escape artist on a leash and fence your yard as well. Invisible fencing is not a safe solution as it allows larger dogs to come onto your property possibly harming your much smaller pet. Obedience classes provide the building blocks that will make your dog comply with your wishes. Teaching the “Wait” command and using it every single time you open a door will make your life easier and your dog safer.
Canine Houdinis that have proven they can dig or climb their way out of just about anywhere should never be allowed outside unsupervised. Tying a small dog out in the yard is also a bad idea. Tiny dogs can get tangled in the leash or tether or walk up the porch steps and fall off, hanging themselves in the process. Often they become aggressive to anyone who approaches. The solution to this problem is to keep your dog out of this kind of situation to begin with.