It's really true that 40 is just a number. It's all in how you approach it and decide what to do next. When I was 40 years old, I was teaching high school and making about $22K. I decided to go back to school to get my doctorate. It took me 7 years to complete, and now I'm a tenured professor and chair of my department.
Approach 40 with a sense of what new challenges await you and what you can do with the years ahead. Yes, the years go by quickly. Reflect on where you've been. But think about the opportunities that are there for you in the future.
Best wishes!