Don't see him hanging on after he drops out the top 8. Which is also about the point he stops beating up his pet tournaments and he has no chance at Wimbly anymore. I don't see why he'd continue beyond that unless his endorsements make him that much more when playing and being an also ran but that would be a lil weird. Also how much more money does he need lol.
Federer is not going anywhere until he gets permanently injured or incapable of beating a Top 20 opponent. The latter is not likely happening until the former happens. I predict he will be playing until he is 42.