get while the gettin’s good
get while the getting is good
To cease, end, or give up (doing) something before it becomes too difficult or the consequences become too severe. There are some reports that the market is about to take a dive, so I reckon we should get out while the getting is good. Listen, kid, there's no way you can win this fight, so why don't you get out while the getting is good?