Once Odysseus and his men arrive, he decides to split the group, half going with him, half staying back.
"One shipmates, friends, the rest of you stand by; I'll make the crossing in my own ship, with my own company..."(Homer 71-73)
Polyphemus closes the cave with a huge slab of rock, not allowing the men inside to get out.
"...and swung high overhead a slab of solid rock to close the cave."(Homer 142-144)
While Polyphemus was asleep drunk from the wine, Odysseus and his men stabbed him in his eye with a hot rod, blinding him.
"So with our brand we bored that great eye socket while blood ran out around the the red hot bar."(Homer 296-297)
Odysseus and his men escaped by tying themselves under the cattle. This allows them to get out of Polyphemus's cave without getting detected.
"...I tied them silently together, twining cords of willow from the ogre's bed; then slung a man under each middle one..."(Homer 337-339)
"They all pitched in at loading, then embarked and struck their oars into the sea."(Homer 386-387)
After getting out of the cave, Odysseus and his men get back to the other men that were waiting for them. They get the cattle on the ship and sail off.
" 'O hear me, lord, blue girdler of the islands, if I am thine indeed, and thou art father: grant that Odysseus, raider of the cities, never see his home: Laertes' son, I mean, who kept his hall on Ithaca. Should destiny intend that he shall see his roof again among his family in his father land, far be that day, and dark the years between. Let him lose all companions, and return under strange sail to bitter days at home.' "(Homer 443-452)
Since he has too much self-pride, Odysseus revealed who he really was and got cursed by Poseidon. If he didn't get so cocky, we would have gotten home faster and easier, but now he has a journey to face.