At any age, just ship products that are quality and marketable. Have good routines and get things done. Stay well informed and educated. Your only useless when you decide you are useless, everything else is just noise. Averages and means are not necessarily definitive of what individual experience will be.

Technology and mobile/web/games are still young industries, in all new industries they start/skew younger. Radio for instance was young at inception but is now older in terms of age, it takes a couple decades for people to decide it is worth pursuing or starting in.

Being a web developer has only been around for 20 years and being a mobile developer only a decade truly (smartphone era). People are going to skew younger here and more coders are 40-50 and younger. As time goes on this will change and skew older. Incidentally because it is a young industry, there is a large divide of people that grew up with the internet and ones before, same on mobile. I think that hangs over the age thing. Older people used to be bad at tech but most people in their 40s even grew up with it or used it very young. Many of my older coder friends started with commodore 64s, Apple IIs and had to find answers before Google, they are now mobile/game/app/web developers. Many of them are more knowledgeable than younger coders today may ever be because they were in the time when everything was being built and the layers were easier to see. There is tons of cruft for a young coder to navigate and once you get out of college (22-24) or masters (27-30) and work for 5-10 years and get your head around this skill, they call you too old, it is a bit cruel but goes back to the young industry bit.

On the brightside, our industry is also unique, we can break out on our own and still compete enough to provide a living. In other industries and lines of work, the costs to startup are immense and risky, bootstrapping is easier in technology. Either in freelance or software as a service or starting something, there is always an option if you keep coding/building/shipping/solutions. Programming is a meta skill like business and marketing that allows you to literally go into almost any industry.

Most people in tech around their late 30s or 40s want to start their own thing and that is a benefit. Young developers may be too uncomfortable doing that because of their confidence and experience. Even lawyers and doctors, if they don't start their own practice, put up with the same push around that everyone else does as they age and get experience. What you need to do is find your own vehicle around this time so you can navigate the waters with a little more command.

Just ship and build things, don't get caught up in the averages. There is a lack of coders still that can deliver from start to live, in fact this situation appears to be getting worse. Provide that and you will always be marketable.

Side note: if you are over 40, I'd suggest paying for your own individual independent insurance. I feel health insurance is another pressure on older engineers in startups at least. I have seen at least two guys get run out based on health conditions and age. Once health insurance is separated from the job, ageism is less intense at these types of places.