Why did Jimmy confess everything at the end?

Sorry I may have missed something as I absolutely binged all 6 seasons over the last 2 weeks, but in the last episode why did Jimmy sabotage his own case to such a degree?

Couldn't he easily have kept Kim out of prison while only getting himself 7 years? Or was it an act of conscience finally kicking in after everything?