We know how to stop piracy. Anyone who has ever read a book on maritime history knows how it's done. Whether we choose to do so or not depends only on how much our collective conscience will bother us if we do opt to punish the havens. My part of that conscience is just fine with it but nobody asks me...
Piracy is an industry, which does not operate in a vacuum. They need port facilities and repair facilities for their boats. The pirates have homes. They contribute to the local economy. The whole village is the pirate support infrastructure.
The pirates are effectively operating in a state of war against the rest of the world. The only effective treatment would be for the rest of the world to treat the Somali coastline like it would have treated enemy bases during WW2. Namely, carpet bomb any village from which pirates operate.