ofcourse the ending didn't go well with the rest of the story
there's no denying that..he was acting so notoriously all along, kept lying to her right from the start about his joblessness to his due prison sentence..he was also rude to her quite a few times and got away with all of this! Why'd you lie to your wife? He provided every reason to his wife to become suspicious of his actions! The ending didn't make any sense. His character wasn't that kind of person who'd get intimidated by a prison sentence and lose all hope and think about killing himself!
The writing fell short of expectations here!