What saved Yelsin was not the deal he made with Putin but more that he was in such poor physical shape that it was clear that he could not possibly be a threat to Putin. The deal he made with Putin was more about saving his family from prosecution for the various looting they did during Yelsin's reign. Putin was glad to keep his end of the bargain only because there was zero chance of political revival for the Yelsin clan. That might be a way out for Erdogan if and when he is ready to step down. Perhaps he can have a fake heart attack and then claim that he is in a near comatose state. Then he can retire and hope his successor does not find out about it.
When Mubarak resigned, he was immediately admitted to a military hospital where he has been "undergoing treatment" ever since, even when he was ostensibly serving a jail sentence.
If Erdogan and his regime are really overthrown, it's best for him to book a private jet somewhere, perhaps a Central Asian republic which can be trusted by both Erdogan and the new government to keep him safe and under surveillance.