That's the secret to a long career! You always have to keep learning and doing. I am retired now, turned 69 a couple of weeks ago. I took on my last job in 2004, when I was 61. Most of my co-workers at that company were in their 20s and 30s. In that job I was constantly learning new technological things, largely by talking to co-workers and by buying and reading lots of books, and by reading lots of code. Learned PERL and VXML and XSLT. I had learned Java in my previous job (from age 58), and designed and implemented a plug-in for Eclipse. Since retiring in 2006, I have dabbled a bit still with Eclipse, and helped some local activists build a website. Learned and used PHP (why do /.'ers badmouth PHP so?) to do it.
If you love doing it, keep stoking the fires and shovel in all the learning you can. You do not have to be over the hill at 40.
As for what to tell young people about CS: I found that all the things I knew about CS (self-taught) were enriching to my thought processes, and discrete mathematics often gave ideas for programming solutions.
The one consistent answer I have always given to any student who asked me "what should I study?" is "Learn to write clearly". After all, your legacy will be the writings you leave behind.
I believe I have shared before on /. my story about battling a production system that automatically restarted itself every midnight and had an O(n^2) process embedded in the startup sequence (no, I did not put it there) which worked against an ever-increasing set of data. Eventually the startup time was clearly headed to become 24 hours+. CS knowledge certainly helped solve that one, though it took several all-nighters to do.