I understand you wanted a happy ending for Jaime, and for him to complete his redemption. The problem is, that while he made great strides in becoming a better person, and realized Cersei was a horrible queen, he never stopped loving her and, with the thread she would be deposed and possibly killed, he had to be with her.
It makes complete sense as to who he was as a character, even after all his growth as a person.