This sounds about right for most pro sports; few continue as players in their 40's, especially in the higher impact / energy sports like basketball.
I think most devs can delay burnout/leaving the field if they begin viewing programming as a means to an end, e.g. "programming as a way to build their own business," or "using programming knowledge to mentor others," or "using programming knowledge in another domain they're interested in to great effect."
Money. If you are financially independent, you are done with the field. If you are financially dependent, you are burnt out.