1. Somali pirates take ship.
2. Crew trained in anti-piracy fights back, retakes ship.
3. Pirates escape but take captain as hostage.
4. Crew sails ship to Kenya.
5. US Navy negotiates for captain with pirates and Somali elders.
6. Talks stall because US insists on pirates receiving justice.
7. US snipers shoot 3 pirates guarding hostage.
8. Captain freed.

Good job :)

I don't think anything other than consistent slaughter will teach these people their lesson.

Yes, the next act of piracy is now more likely to be violent. It may result in pirates changing their business plan - from planning to take the crew hostage and negotiate a ransom, to just offing the crew outright and reselling the ship and its cargo.

Then again, this may discourage pirates if they don't have the connections to resell the ships, or the intel to know which ones carry valuable cargo. We'll see.