Then you sell it for scrap.
It will have to be towed/sailed to some suitable location and then people have to actually go about the process of scrapping it. Unfortunately the cost of all of this exceeds what you can sell the scrap for, so again, nobody is going to buy the ship.
The point is not to recover losses, although ideally it would help. The point is to have severe financial consequences so it stops happening.