Earth is considered a closed system because though heat enters, its mass remains essentially constant. The matter of Earth remains on Earth and in its atmosphere because gravity prevents it from migrating into space. Earth is also considered to be more of an approximation of a closed system because some matter does enter from space.
There are three types of systems in thermodynamics. The first type is an open system, such as the human circulatory system, in which heat and matter are exchanged with the surrounding area.
Another type is an isolated system in which there is no exchange of heat or matter with the surroundings. An isolated system is not possible in nature because there is always an exchange of energy between a system and its surroundings. Earth is among the third type, a closed system in which solar radiation comes into the Earth's atmosphere and onto the planet itself, but matter does not leave the Earth.
Earth is also considered to be more of an approximation of a closed system because matter in the form of meteors occasionally enters the atmosphere and strikes the planet's surface. Scientists think the Earth's iron core resulted from a massive asteroid strike about four billion years ago. This strike broke off some of the mass of the Earth, causing the moon to form.