Wikipedia says – The time of sunset is defined in astronomy as the moment when the trailing edge of the Sun’s disk disappears below the horizon. Near to the horizon, atmospheric refraction causes the ray path of light from the Sun to be distorted to such an extent that geometrically the Sun’s disk is already about one diameter below the horizon when sunset is observed.
The spinning Earth lit by the Sun as seen from far above the North Pole. All along the terminator, the rays from the sun hit Earth horizontally, neglecting any atmospheric effects and Earth’s orbital motion.
Sunset is distinct from twilight, which has three phases, the first being civil twilight, which begins once the Sun has disappeared below the horizon, and continues until it descends to 6 degrees below the horizon; the second phase is nautical twilight, between 6 and 12 degrees below the horizon; and the third is astronomical twilight, which is the period when the Sun is between 12 and 18 degrees below the horizon.Dusk is at the very end of astronomical twilight, and is the darkest moment of twilight just before night. Night occurs when the Sun reaches 18 degrees below the horizon and no longer illuminates the sky,
The Colors of the Sun
As the sun sets, the light must travel through more of the atmosphere before the rays get to you. By more atmosphere, that means more molecules which scatter the blue and violet light. (Think of it like a glass of water – at mid-day, the light is refracting through the center of the glass of water. With a sunset, the sun is refracting across the surface of the glass of water). If the path is long enough, the blue and violet lights go further than our eye can see. This leaves the pink, orange and red colors for us to look at. So that’s why sunsets are usually pink, orange and red.