So how about:
Sell the ship, let the crew live in a nice hotel, book them a 1st class flight back home, then bill the country under who's flag the ship was operating. If they can't / refuse to pay, import sanctions.
That way, you're not punishing the crew, yet making such behavior financially uninteresting. That's the only way because the person who decided to send that ship there is probably far away and busy counting profits.
Also, it's a lot easier to capture the boat if that's a positive experience for the crew. They might flee from a trip to prison but few people run from a paid vacation offer.