There is an excellent book called "The Peter Principle" that is exactly about this sort of thing. The concept it uses is that people get "promoted to their level of incompetence." In other words, you are a great programmer, so you get promoted to manager because it's a promotion. You are a so so manager. You stay there until you retire, though you would have added a lot more value as a programmer.
It has a few examples of people who managed to avoid getting promoted out of the thing they truly excelled at. One gardener had a personal quirk of failing to pick up his paychecks on time. This drove management crazy and kept him gardening instead of whatever people did who got promoted.
Another individual had an office that looked like a paperwork bomb had gone off. There were untidy stacks of paper everywhere. Management was convinced he was a disorganized mess, though he had a very efficient paperwork system wholly unrelated to the mountains of papers stacked all over the place.
I highly recommend the book. After you have read it to establish a mental framework, you might need to read up on social psychology to come up with a strategy for convincing management that promoting you out if programming is a silly idea.