Final answer:
Comets leave the Oort cloud when they are diverted into the inner solar system due to the gravity of nearby stars.
Step-by-step explanation:
Comets leave the Oort cloud when they are diverted into the inner solar system. The Oort cloud is a spherical collection of ancient icy objects that surrounds the Sun out to about 50,000 AU. It is believed that the gravity of nearby stars can disturb the orbit of a comet in the Oort cloud, causing it to move closer to the Sun and become visible to us.