So, let me say that my answers come mostly from If a pirate I must be by Richard Sanders and Villains of All Nations by Marcus Rediker.
First, most commonly the end to piracy was getting caught by the admiralty in terms of dealing with the British. Being caught as such you were probably hanged. Pirates who claimed to be forced into piracy, which was pretty much everyone might only be sentenced to hard labor in the mines or be pressed into naval service in the admiralty. So, the punishment of mutiny was being back on a boat to work for the navy again. This kind of puts you back in "normal society" since being press-ganged was pretty normal. However, this doesn't really give much in the way of freedom in terms of entering society.
As for retiring from the pirate life, it seems that there may have been some safety in retiring in the colonies. Especially in parts of the American colonies seemed to be pirate friendly, and some (mostly injured) pirates did take some of their pirate earnings to live modest lives among the colonists. Since pirates would often bribe governors and merchants, an ex-pirate would be overlooked so long as they could pay their own way. It wasn't like some of the colonies weren't filled with ex-cons anyway. Now again this is assuming being a colonist is part of "normal society".
Now, as far as getting caught. Consider we have a lot of information on famous pirate captains and their end because earning a reputation was likely to get you noticed and eventually arrested. However, ships had lots of crew who joined, defected or got maimed whose names and fates aren't recorded probably because they vanished in the annals of history probably to live a boring life of a sail mender or cook or carpenter after leaving the pirate life behind.