Any long-term commitments can be potentially worked around via bankrupcy. As long as we allow companies to take the full responsibility for consequences of their actions, and completely absolve their owners, the system will not work that great.
I'm sure you could just contrive an accidental sinking, or even better have the ship taken by "pirates" who happen to leave some cash in the lifeboats with the dispossessed.
Seems like you'd have to just outright ban selling it to foreign owners?
Otherwise someone will make a "legitimate" business in a country that doesn't ban selling to (non-compliant) scrappers, whose job in life is to purchase old ships and sell them to scrappers. Maybe hanging on to them for a bit first to make it slightly less blatant...