You gotta think that 110 titles is on his radar as well. He has 13 to go to pass Connors. He had 7 last year, 2 this year so far. Let's say he wins 4-6 more this year, that would leave him with 6-9 to go. He could theoretically do that in 2019, but probably needs 2020.
I'm not saying that he won't retire until he gets #110, but that three more years makes 110 a certainty (barring injury, serious decline).
Let's say it is the end of 2019 and he's got to 110, he's won a couple more Slams to get to a comfortable 22, he finished 2018 as YE1 and has 350+ weeks total. 2020 is looming and he's finding it just a bit more challenging to motivate to get out there and practice, and is enjoying life at home with the family...
Even then, I don't see him outright retiring. As he has said, he'll "phase out." This is totally conjecture, but I could see the following:
2018: almost full season, including a couple clay tournaments (~14 tournaments).
2019: Reduced season, similar to 2017 (~12 tournaments).
2020: Selective season, maybe three Slams, grass and favorite hard courts, Olympics (~10 tornaments).
2021: Slams, favorite tournaments only (e.g. three Slams, Halle, Wimbledon, Basel). (~6-8 tournaments).
2022: Retired.
Or something like that. That's just one hypothetical scenario I could see happening.