McIlroy has been largely injury-free since rupturing an ankle ligament in 2015, which forced him to miss the defence of his Open title.
Speaking before the Players Championship at TPC Sawgrass starting on Thursday, the 35-year-old said he intends to retire with a “little bit left in the tank”.
“I can acknowledge how lucky golfers are to be able to do what they do for so long compared to other athletes, so whenever I feel like the time is right, I’ll have no problem moving aside and letting the next generation do their thing,” said McIlroy.
“When I’ve achieved everything I want to achieve in the game and I get to the point where I don’t think I can maybe do that any more.
“I don’t want to be out there embarrassing myself. I’d like to walk away maybe a little before I should.
“There’s always one more, but that’s OK. If you can come to terms with that and walk away on your own terms, then that’s a good thing.”
Asked about the prospect of playing on the Champions Tour, he said: “Absolutely not. I will not play Champions Tour golf.
“I’ve said a lot of absolutes in my time that I’ve walked back, but I do not envision playing Champions Tour golf.
“Something has gone terribly wrong if I have to compete at golf at 50.”