1. The OP is obviously far ahead technically than his work environmment. He has the experience, know the practices and can improve the software process.
2. Second but key, he sucks at working in a team and also at communication. You don't change a mess such as the one he describes in 5 months. That culture of the company, if you are not the boss, only changes by soft proposals, influence, bond building, debate.... Nothing is going to change to new practices or behaviours if not for conviction (or fear). It's a slow process, an not one you can win only by logic. The subject is huge.
That said, I agree that it was better for him to leave.