In top leagues a player playing to forty plus years is unheard of, goal keepers can -buffon- let's not run the time/age limits of Messi playing football. There are other things that can stop or put to end the professional playing football career of a player
+ Injuries and reoccurring effect of surgeries
+ Club/personal/families-this mostly family opinion- the club/personal can be problems.
Even the players want to keep playing these and more can make them have a changed heart
Many contributive factors (as said): ambition in the football leauge, season, happiness when playing football, sudden injuries and effects from injuries and surgeries, family effects. Many things.
Regarding to injuries that force great players to end their career, at least I know Van Basten. He is at his highest form before his ankle injury. Some players like Batistuta has longer career but after his retirement, he has many physical troubles with past injuries from football.
https://www.dailyrecord.co.uk/sport/football/football-news/marco-van-basten-reveals-rangers-21600633https://www.espn.com/soccer/argentina/story/3155942/gabriel-batistuta-has-difficulty-walking-after-retiring-from-footballThat second article about Batistuta was an interesting read. Playing professional football for the most part of their lives, it certainly leaves a mark on your body. But that it can really be that bad ... Horrible.
With examples like Batistuta in mind and the increasing pace in modern football over the last decade, it's no wonder that we see more and more players retiring rather early. Benedikt Höwedes (32) and André Schürrle (29) are just the most recent examples that came to my mind. So that Messi will play till his fourties is not gonna to happen. Why would he? He's made enough money for his future generations and won everything with Barca. So why risk his health? If I were him, I would've retired after last season and after this drama with him wanting to leave Barcelona but couldn't.