You do not have to become an "X who programs" when you hit 40. I've worked with plenty of talented developers over 40, all whom see themselves as developers, not as "VPs who happen to develop".
I think you're getting confused by the other phenomenon involving roles, which is that once you accept the management track, you start losing dev mojo; cf. the CTO who loses their commit bit.