I have many times taken over projects that were so deep in technical debt that only extreme surgery would save it from being killed. It can take a long time to turn those projects around and make them healthy again but it is possible.
The first step for me is always to add solid tests. On one project (for example) it took 8000+ test cases to make it solid, maintainable, and bug free in production.