Washington (CNN) Nikki Haley is getting out of the Trump administration with her stature elevated and political prospects brightened -- not something that could be said for most top political power players who leave the President's reputation-crushing fold.

Outshining the showman in chief in her Oval Office goodbye Tuesday, the outgoing US ambassador to the UN pocketed a valuable endorsement for a political career no one thinks is over.

The President, in comments that might one day find new life as a campaign ad, said Haley "has been very special to me. She's done an incredible job. She's a fantastic person, very importantly -- but she also is somebody that gets it."

As she sat smiling beside the President, their unusual photo op, and the generosity of a President whose good mood may owe much to his current political roll, suggested Haley has the essential ingredient of high-flying political careers -- timing.

The coming days might shed more light on Haley's decision to quit. She could cash in on her chance to make some serious money. And as odd as it might seem for a top politician, her stated reason -- that she just wants a rest from public service after years as South Carolina's governor before her UN service -- could actually be true.

Haley's sudden announcement left everyone in Washington asking, why now?

But a more relevant question, politically at least, is why not now?

It's widely assumed in Washington that Haley has a presidential run in her future -- indeed, she felt it necessary to inform Trump in front of the White House press corps that she wasn't gunning for him in 2020.

With the future in mind, it makes sense to bank political gains she has accrued in nearly two years at Turtle Bay in New York.

During that time, she has managed to avoid antagonizing the President while raising her own profile -- an astute balancing act that in the jungle of the Trump administration might have been hard to sustain for much longer.

She went before her relationship with the President visibly decayed -- the comparisons between her departure and the ugly exits of former Secretary of State Rex Tillerson and former national security adviser H.R. McMaster were notable. Other former Trump confidants, such as former New Jersey Gov. Chris Christie or former political guru Steve Bannon, were also given the cold shoulder.

And she's still popular -- an April Quinnipiac University poll put her approval rating at 63% -- a good 20 points higher than Trump's, which makes her double game at the United Nations even more impressive.

Haley's double game

JUST WATCHED Watch Nikki Haley on the world stage Replay More Videos ... MUST WATCH Watch Nikki Haley on the world stage 01:44

Haley became a face of Trump's "America First" policy, pushing, for instance, plans to overhaul the UN that the President enthusiastically backed -- but she also was able to ensure that she never became defined by the doctrine.

She fashioned a reputation as a hawk, managed to adopt orthodox conservative positions on issues like Russia and human rights without alienating Trump, and added valuable foreign policy experience to her résumé, which already boasts executive experience in six years as the Palmetto state's first female governor.

Often, her work as ambassador happened to boost credentials that would be useful for a potential presidential candidate -- for example, in her staunch support for Israeli Prime Minister Benjamin Netanyahu's right-wing government, which will win approval among evangelical voters.

There might simply be little more to gain politically by sticking around at the UN.

By announcing her departure before a possible midterm election meltdown, she avoids appearing disloyal to the President in an expected exodus of senior officials.

Rep. Mark Sanford, R-South Carolina, who preceded Haley as governor, said they both shared a political adviser, Jon Lerner, who followed her to New York, and that Lerner thinks something else is going on.

"He reads the political winds very, very, very well," Sanford told CNN's Jake Tapper.

Political handicappers might also note that Haley's political star power meant there was something in the session before the cameras for Trump as well.

While there were some whispers in the White House at the timing of Haley's departure -- given that the Brett Kavanaugh Supreme Court confirmation drama exposed the President's trouble with female voters -- Trump clearly benefited from a TV moment when he could praise a strong, popular, Republican woman and bask in some plaudits from her.

Every recent sign from Washington has suggested that the running room given to Haley so far might narrow in the months to come, with national security adviser John Bolton tightening his grip.

Haley already understands the political dangers of appearing out of the loop.

One of her most difficult moments as UN ambassador came when she announced on television in April that the administration would impose new sanctions on Russia, only to be cut down by top White House economic adviser Larry Kudlow, who suggested she might have been momentarily confused.

Her sharp comment turned an embarrassing moment into a political win, but also showed the potential risk going forward of becoming estranged from the foreign policy team in the White House.

This might be the point, then, when the political benefits of staying in the administration are outweighed by the advantages of getting out.

Foreign policy storms loom

JUST WATCHED Haley contradicts Giuliani on Iran Replay More Videos ... MUST WATCH Haley contradicts Giuliani on Iran 01:14

The first two years in any presidential first term are often a period of setting the slow-moving infrastructure of a foreign policy in motion -- and the consequences of a pivot become clear later on, in the final two years.

The administration is heading for geopolitical affray on multiple fronts, including ratcheting up tensions with Iran, engineering a new confrontation with China and seeing its relations with Russia steadily worsen. For all of Trump's boasts, it's hard to see any big foreign policy wins on the horizon.

Should any of those showdowns develop in an adverse way that erodes the Trump administration's credibility over the next two years in a war-weary nation, she will have the luxury of being out of office and free of responsibility at the time.

When she leaves the administration at the end of the year, Haley will embrace a new sense of political freedom, which she hinted at in her resignation letter.

"I expect to continue to speak out from time to time on important public policy matters, but I will surely not be a candidate for any office in 2020," Haley wrote.

As a private citizen, Haley can pick and choose her moments -- campaigning for Trump if he remains popular with Republicans running up to his re-election race in 2020 while distancing herself from positions that could damage her down the road.

If an attractive political post comes up -- for instance, should South Carolina's Sen. Lindsey Graham change his mind and enter the administration -- she will be ideally placed.

If Trump wins in two years, she will have more freedom than someone like Vice President Mike Pence to pursue her own presidential ambitions outside the inner circle. Or she could choose to get back in for a while, and might be in demand to succeed Secretary of State Mike Pompeo at Foggy Bottom.

If Trump loses re-election in 2020, Haley would be immediately at the top of the list of potential Republican candidates for 2024.

Whatever happens in 2020, and given the GOP's current plight among female voters, it is likely that future leaders will be looking to close the gender gap.

Haley's timing could be spot on again, if Republicans go searching for a female candidate who is popular, is experienced as a governor, has a foreign policy résumé, is well regarded by Trump voters and comes from a crucial early primary state.