Jonah disobeyed God's command and fled in a ship, but God who brings "out of the eater came something to eat, and out of the strong came something sweet" (Judg. 14:14); God who is able to turn evil into good, was also able to make use of Jonah's disobedience.
If it was through Jonah's obedience that the people of Nineveh were to be saved, it was through his disobedience that the mariners would be saved.