Mr. Ganier is on to the heart of the matter. It sounds a bit simplistic, or even condescending, but it's not being evasive to say that you cannot allow yourself to get in such a situation.
Another way of looking at the issue is by one of definition. By definition, you cannot sail off a lee shore as you are unable to point high enough to avoid grounding. If you are able to sail off a leeshore then, the point can be made, it wasn't really a leeshore; just a really intense exercise in beating (sailing to windward).
In all due seriousness, the issue arises at the point at which the determination is made that you can sail out of there as you approach the coast or shore. Making that decision without due regard to wind shifts or current can allow you to end up in a leeshore situation. The error occured earlier though, when you either did not allow for, or were aware of, the changing nature of conditions.
The best thing to do is to avoid impulses to go sight-seeing inshore, leaving those situations where you might confront a leeshore to the requirements of entering port, if then. Of course, knowing how well your boat handles to windward is of fundamental importance in determining what may be a leeshore for you.
A sea anchor and excessive ground tackle are not amiss either.
“Scientists are people who build the Brooklyn Bridge and then buy it.”
Wm. F. Buckley, Jr.