Roger Federer knows how he wants his career to end.

In an interview with CNN, the 37-year-old tennis great spoke of how he envisions writing his final chapter.

“I hope it doesn’t end with an injury,” Federer said. “I’d like to go out on my terms.”

Federer, who dealt with back issues in 2013 and freak knee injury in 2016 that led to surgery, saw fellow star Andy Murray, 31, announce his plans to retire this season because of the effect his injuries are having on him. The Swiss star hopes that won’t happen to him, but he doesn’t have his heart set on a grand exit either.

“I don’t have the fairytale ending in my head saying there has to be another title somewhere, and then I have to announce it big and say, that was it, by the way, guys. I don’t have to have it that way,” said Federer, who won three of his 20 major titles in the past two years.

In his mind, the moment for that type of finale may have already past.

“If I wanted it that way, I could’ve maybe said it after the Australian Open [in 2017] when I beat Rafa [Rafael Nadal] in that epic final. I don’t know if it’s ever going to get better than that, because that was it for me.”

He also told CNN he will not do a farewell tour. It’s something former coach and childhood idol Stefan Edberg advised against. In an interview with Australia’s Sunday Age, Federer said he was hit hard by Murray’s retirement and seeing him “struggling.”

‘‘You want somebody to go there and feel like he’s happy to retire,” Federer said. “The problem is it’s not his decision, it’s the body’s decision and that naturally hurts.’’

Federer’s hope is that it is him and not his body deciding when it’s time for him to finally walk away from tennis.