Kinda similar to how Kobe Bryant knew it's time to retire from the game of basketball. He said in an interview (https://youtu.be/Ya8hY0S-8t0?t=54) that he knew it's time when during his morning meditations, his mind will not drift to basketball anymore.
What I wonder is how did Kobe know this was a sign that he was done. Why didn't he think he was just burned out and maybe just needed a break before returning to the game? How can you tell when you're burned out vs. just being completely done with it all?
I think because he was already 37 or 38 at that time, and was suffering from injuries, too. There was no point continuing if both his body and mind are not the way they used to be.