* O’Brien says he’s leaving ‘the best job in the world’

* He takes shots at, as well as thank, NBC (Adds details, quotes)

NEW YORK, Jan 22 (Reuters) - Conan O’Brien ended his brief stint as host of the “The Tonight Show” on Friday, taking shots at NBC but ultimately taking the high road and thanking his former employer for a chance at “the best job in the world.”

“This company has been my home for most of my adult life,” O’Brien told the Burbank, California, audience and home viewers during his final moments on the show, which began with a sustained standing ovation from the fans who chanted “Conan, Conan.”

“Thank you, that’s going to have to last me awhile,” he cracked once they settled down.”

Late in the show the host struck a more serious note, saying “Tonight I’m allowed to say anything I want.”

“I am enormously proud of the work we have done together, and I want to thank NBC for making it all possible,” he said.

Still, in his opening monologue O’Brien offered a list of possible uses for the soon-to-be vacated studio built expressly for his widely publicized assumption of “Tonight Show” hosting duties last year.

Among the suggestions were a “storage facility for apology notes to NBC stockholders,” and “leave the studio cold and empty and rename it “The World’s Largest Metaphor For NBC Programing.”

Joining O’Brien for his last show were actor Tom Hanks, comedian Will Ferrell who appeared on O’Brien’s first “Tonight” show, and singer Neil Young, who performed “Long May You Run.”

Thursday night’s show featured a surprise appearance by Ben Stiller, as well as an X-rated performance by Robin Williams that targeted NBC and was bleeped out several times.

In one of his trademark self-deprecating jabs, O’Brien joked that when the inevitable HBO film is made of the debacle, “I’d like to be played by Academy-Award winning actress Tilda Swinton,” who, like O’Brien, is a fair-skinned redhead.

Steve Carell of the NBC satirical comedy “The Office” conducted O’Brien’s “exit interview” in a surprise appearance.

“Did anything trigger your decision to leave,” he inquired, deadpan, before presenting O’Brien with a termination packet which included information on continuing education. Finally Carell asked the star for his company ID badge, which he fed into a shredder.

JAY LENO TO RETURN FROM MARCH

O’Brien’s swan song in one of U.S. television’s most coveted and high-profile jobs capped two weeks of acrimonious sniping, much of it on-air, that ended with a $45 million exit deal which will allow the show’s previous host, Jay Leno, to return to the flagship late-night talk show.

After more than a week of negotiations, General Electric Co's GE.N NBC said it had agreed to release O'Brien from his contract after seven months, and that he would be free to take a new job elsewhere after Sept. 1.

The struggling network, already bottom of the four big U.S. TV networks and now the butt of jokes by its own and rival comics, said Leno will return as host of “The Tonight Show” on March 1.

Leno hosted the program for 17 years, making it the top-rated late-night talk show on U.S. television. He handed over to O’Brien in June, only to see audiences slump, while Leno’s own prime-time talk show floundered as well.

Leno’s name went unmentioned during O’Brien’s final show.

At the conclusion, the outgoing host somberly told his audience:

“Walking away from ‘The Tonight Show’ is the hardest thing I have ever had to do.

“This is the best job in the world, I absolutely love doing it ... I did it my way, with people I love and I do not regret a second. I’ve had more good fortune than anyone I know.”

He ended the show by joining Ferrell in a rendition of Lynyrd Skynyrd’s “Free Bird.” (Editing by Mohammad Zargham)