APAD:Get out while the going…
Get out while the going (getting) is good.
Get out of a situation while it’s still easy to leave on good terms.
Example: With the stock market at an all-time high and further upside looking difficult, we decided to sell our shares and get out while the going was good.