Under the United Nations Convention on the Law of the Sea,
"Every State shall require the master of a ship flying its flag, in so
far as he can do so without serious danger to the ship, the crew or
the passengers to render assistance to any person found at sea in
danger of being lost, to proceed with all possible speed to the rescue
of persons in distress, if informed of their need of assistance, in so
far as such action may reasonably be expected of him, and after a
collision, to render assistance to the other ship, its crew and its
passengers and, where possible, to inform the other ship of the name
of his own ship, its port of registry and the nearest port at which it
So the obligation to assist and carve outs to it will depend on the specific domestic maritime law of the state parties to the convention and how they implement their treaty obligation and punish violations of their domestic law.
Realistically, of course, a jurisdiction will be unlikely to prosecute a captain whose aid is explicitly rejected in front of witnesses, especially if there would be any danger to his crew in trying to assist against someone's will.