"Get (in/out) while the gettin(g)’s good” means to take advantage of market conditions, getting in or getting out at just the right time to make or save the maximum amount of money. “Get in while the getting’s good” has been cited in print since at least March 1910, while “get out while the getting’s good” has been cited in print since a least 1912.
Wiktionary: get out while the getting’s good
to get out while the getting’s good (phrasal verb)
1.(colloquial) To leave at an opportune time or before adverse conditions appear.
2.(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.
The Free Dictionary
get (out) while the gettin(g)’s good and get (out) while the goin(g)’s good
to leave while it is still safe or possible to do so. I could tell that it was time for me to get while the gettin’s good. I told her she should get out while the gain’s good.
March 1910, Santa Fe Employes’ Magazine, pg. 108, col. 1 ad:
Get in while the getting’s good.
(The Palace Clothing Co.—ed.)
By Sarah Comstock
Garden City, NY: Doubleday, Page & Co.
“Take your choice; get out while the getting’s good, or we’ll boom Glad-hand by starting a Boot Hill right here.”
15 January 1912, Saginaw (MI) News, pg. 2, col. 1 ad:
It’s up to you now to get in while the getting’s good.
(Griggs & Rutenschoen, clothes and furnishing store—ed.)
February 1912, Everybody’s Magazine, pg. 193, col. 1:
Others — and by far the greater number — are frankly engaged in “getting theirs while the gettin’s good.”
8 March 1912, New Orleans (LA) Item, “Burns will try to knock out Kenrick” by Mack, pg. 12:
“Maybe in a year from now he will not be able to make the bantam limit, 116 pounds, but just now he can, and we want to get Coulon while the getting’s good.”
22 March 1912, Los Angeles (CA) Times, pg. I2:
LA FOLLETTE’S PLANS.
Wisconsin Man Says He’s Going to Get Around as Much as Possible While the Getting’s Good.
November 1915, The Silent Partner, vol. 11, no. 1, pg. 79:
You may not reach the top, but if you can cash in, for the love of Mike, get your money while the gettin’s good.
24 July 1922, Boston (MA) Daily Globe, “Mutt and Jeff” comic strip, pg. 13”
MUTT AND JEFF--Jeff Believes in Getting It While the Getting’s Good.
Your Government urges you to get your coal while the gettin’s good.
Author: United States. Solid Fuels Administration for War.
Edition/Format: Book : National government publication : English
I gotta get my sugar (while the gettin’s good).
Author: Rusty Gabbard
Edition/Format: Musical score : English
OCLC WorldCa trecord
Get while the gettin’s good
Author: Bill Anderson; Jordanaires (Musical group)
Publisher: New York : Decca, 
Edition/Format: Music LP : Country music : English
OCLC WorldCat record
Getting Out While the Getting’s Good: Banks and thrifts that felt pressured into selling in 1994 at least got some good prices for their pain. Sellers in 1995 may not be as lucky
Publication: US BANKER, 105, no. 3, (1995): 67
Database: British Library Serials
Get in while the Getting’s Good – Why Buyers and Sellers Should Take Advantage of Today’s Real Estate Market
By Dan Steward
RISMEDIA, February 16, 2011—The Case-Shiller Index is one of the country’s most popular ways of measuring the movement of home prices. And in its latest rating, which went out in late December, the verdict was: Prices are down.
Los Angeles (CA) Times
Afghanistan: Getting out while the gettin’s good
June 24, 2011 | 2:29 pm
New York City • Banking/Finance/Insurance • (0) Comments • Monday, August 01, 2011 • Permalink