I trained my dogs to not go within 10 feet of the door unless on a leash. Not an option. One dog I had to take back to sit 10 feet TWENTY THREE TIMES before she GOT IT, lol. Anything but the door, she would stay til the end of time, but that door, lol.
Work on stay, then work on stay back away from the door without opening it, toss treat. Then work on cracking the door, toss treat. Work up to opening door, standing slightly outside it and release as toss treat right before closing it.
And, frankly, know where your dog is before you open the door. If you have to put up connected gates around the door for now, do it. A loose dog is often a dead dog.
And while I don't advocate punitive measures I know a gal with a Siberian Husky who ran once and got hit by car. Something like $5000 vet bill later, the dog tried to bolt again. She had a friend stand outside the door with a rubber trashcan lid and wack the dog as it started out. She said never tried it again. I'd go with a super soaker instead, but the issue of safety is the one area I wouldn't fault some punitive responses. (okay and not so mild punitive when it comes to snakes… use of shock collars there may be more than justified)