After hearing Utnapishtim's story he realized that only the gods can give eternal life. Utnapishtim offered Gilgamesh one last chance to achieve immortality without the god's help. He told Gilgamesh about a plant at the bottom of the sea that could grant immortality.
So Gilgamesh went to the bottom of the sea and retrieved the plant. On the journey back to Uruk, Gilgamesh stopped to take a bath, and a snake ate the plant, shedding its skin and becoming young again.
After failing his quest for eternal life, Gilgamesh went home. Learning a lot on his journey Gilgamesh became wiser.