@hisvictor That's so scary!
I would recommend searching for tracking devices for kids with autism. (I am not saying I think your kid has autism. I just think that enough families of kids with autism would need some kind of tracker that it would probably be good search terms to find what you are looking for.) You might also try for kids who elope, wander, or abscond. No advice on specific products - just key words to google.
Second, you need to look further into the behavior. If there is a diagnosis (or a history of trauma) causing the behavior, it can get worse as they get older if they don't get treatment. You may need a different parenting toolset than what works for a typical kid. If you haven't already, I'd start with your pediatrician and be very specific about the behaviors. This is not a quick answer - I think the tracking device is needed.
Additionally, there could be other measures to help secure him. For example, if he runs when you leave, wait outside out of view for 10-15 minutes in case he runs. Of if you have cameras, watch. Add alarms and latches to doors. He'll figure them out, but they may slow him down. Obviously patch the hole in the fence.
Additionally, if you can figure out triggers (you leaving) have alternatives to help. If he likes to hide, a small play tent with a bunch of sensory toys and favorite things inside, might be a good option. If he wants to run, swinging or crashing into something might help. It might help if Grandma has something special and fun or tasty to distract him immediately when you leave, until she settles in.
Best of luck. That is so scary. I'm glad he is okay and it sounds like you are doing a great job trying to figure it out.