Now that he's finished urging young people to "Seize the Day" (more or less), Ecclesiastes turns to lamenting old age and the days of darkness. He says it's like the sun, the moon, and stars all going out.
He goes on to recite a poem. It might be about how everything is doomed to fall apart and decay, or it might be an allegory for how the human body itself will decay. Maids will stop working, light will go out in the windows, the market will close. The spring will come back, and the trees and flowers will bud and blossom, but the human beings who are dying won't be renewed in the same way.
Ecclesiastes ends the poem by presenting images of decay and destruction—a silver cord being snapped and a golden bowl being smashed. The same way these things come to end, so will human beings. Interestingly, even though he earlier said that no one knows if the spirit will ascend upwards after dying, he now says the body will become dust and go back to earth, but the spirit or "breath of life" will return to God.
Finally, Ecclesiastes ends by repeating the same words with which he began. "Vanity of vanities! All is vanity!"
Oh, and Um… Don't Forget the Commandments
This last part was almost definitely tacked on by someone else. It says (in the third person) that Ecclesiastes was wise and taught people many sayings. But, actually, when you get down to it, there's only one thing you really need to know, and that's to fear God and keep the commandments. Since Ecclesiastes mentions God's judgment, but never mentions keeping the commandments (except for some general talk about righteousness or goodness), we're assuming whoever added this on wanted to make sure people didn't take Ecclesiastes's ideas too far.