I know plenty of parents who have this kind of code with their teen kids, and I love the idea because it lets kids get out of potentially dangerous situations while allowing them to save face in front of their friends. Let's say "Jamie" is supposed to drive your kid home but is hammered after doing shots of tequila (or snorting nutmeg, which apparently is a real thing). Instead of your child trying to whisper over the phone that he/she is in trouble (and risk getting yelled at by Jamie or others), your child can say, "I have a stomach ache" (or "I lost my key" or "I forgot to tell you that your boss called"); no one will know she is using a code to create a safe escape route.
As it turned out, Risa, age 8, needed the code recently (which, unfortunately, we hadn't yet created). She was at a friend's house, and the friend's parents were screaming at one another. Risa felt unsafe because of all of the loud commotion, and worried for her friend who she couldn't help out. Worse, her friend made her promise (with several pinky-swears) not to tell me about the fighting because then I might not let Risa go over there again. Terrified of breaking a promise (we know the power of a pinky-swear), she tried to hold in the story for as long as she could. Thankfully, Risa broke just as I was putting her to bed and told me about the whole "very scary" experience.
This led to a long discussion about families and relationship styles, and how hard it is to watch our friends suffering when there is nothing we can do about it. We talked about when it's inappropriate to keep a secret, and when it's too much to ask. (If your body is getting stomach aches and head aches because you're upset from an experience--true in this case--tell the secret because we can help or at least lighten the emotional load.)
I then told Risa about the code, and that she could call home whenever she felt in over her head and say, "Mom, I have a stomach ache" and I'd come get her, no questions asked. (I explained that the code is only for when there is a real worry; it's not to be used for situations where she doesn't like the type of dinner being served or is kind of bored with the games being played.) We're prepared now, and Risa feels relieved at having the code in place. I hope you will consider setting up your own code with your children before they need it.