فَإِذَا رَكِبُوا فِي الْفُلْكِ دَعَوُا اللَّهَ مُخْلِصِينَ لَهُ الدِّينَ
...
And when they embark on a ship, they invoke Allah, making their faith pure for Him only,
This is like the Ayah,
وَإِذَا مَسَّكُمُ الْضُّرُّ فِى الْبَحْرِ ضَلَّ مَن تَدْعُونَ إِلاَ إِيَّاهُ فَلَمَّا نَجَّـكُمْ إِلَى الْبَرِّ أَعْرَضْتُمْ
And when harm touches you upon the sea, those that you call upon vanish from you except Him (Allah Alone). But when He brings you safely to land, you turn away. (17:67)
Allah says here:
...
فَلَمَّا نَجَّاهُمْ إِلَى الْبَرِّ إِذَا هُمْ يُشْرِكُونَ
but when He brings them safely to land, behold, they give a share of their worship to others.
Muhammad bin Ishaq reported from Ikrimah bin Abi Jahl that when the Messenger of Allah conquered Makkah, he (Ikrimah) ran away, fleeing from him. When he was on the sea, headed for Ethiopia, the ship started to rock and the crew said:
"O people, pray sincerely to your Lord alone, for no one can save us from this except Him."
Ikrimah said:
"By Allah, if there is none who can save us on the sea except Him, then there is none who can save us on land except Him either, O Allah, I vow to You that if I come out of this, I will go and put my hand in the hand of Muhammad and I will find him kind and merciful."
And this is what indeed did happen.
Allah says:
لِيَكْفُرُوا بِمَا اتَيْنَاهُمْ وَلِيَتَمَتَّعُوا فَسَوْفَ يَعْلَمُونَ