Greg Lyzenga, associate professor of physics at Harvey Mudd College, has the answer.

Image: The Nine Planets
COMETS vaporize when their orbits take them close to the Sun.

Comets do not melt in the strict sense of becoming liquid. However, since they are composed partly of ice and other volatile compounds, they vaporize (turn directly to gas) when warmed in the vacuum of space by passing near the sun. It is this escaping gas that forms the comet's luminous tail.

"Near" in this context means closer than several astronomical units (AU) from the sun; one AU is about 93 million miles, the average radius of the earth's orbit. Farther away from the sun than that, it would be hard to tell from physical appearance alone the difference between a comet nucleus and an "ordinary" asteroid.

After many orbits near the Sun, a comet does eventually "expire." In some cases, all the volatile ices boil away, leaving a remnant of rock and dust. Sometime the comet completely disintegrates. Although comets seem long-lived from a human perspective, on an astronomical time scale, they evaporate quite rapidly. Typical comet nuclei may range in size from a small mountain to a large city. So it is understandable that it might take more than a few years for all that ice to evaporate!