get out while the getting's good (phrasal verb)
(colloquial) To leave at an opportune time or before adverse conditions appear.
(idiomatic, colloquial) To sell all or part of one's holdings in stocks, real estate, a business, etc. while conditions are good, particularly in anticipation of a drop in prices.