I was able to retire at 55 last year, so it worked out. The last few years were spent at big companies so there was zero pressure to move into management, there were plenty of people that wanted to do that so they had their fill. I think there was some expectation to move into a Tech Lead type role but if you do some of the Tech Lead tasks unofficially (code practices, mentoring) you should do fine.
At 41 think of it this way. You're older and if you're laid off, would you rather be a middle manager looking for a job or a developer that's kept up your skills?