Here's why:
* The moon doesn't produce its own light. The moon shines because it reflects sunlight.
* The sun is the source of light. When the sun sets, it's no longer shining on the moon.
* The Earth blocks the sunlight. The Earth rotates, and when the sun is on the other side of the Earth from us, it's nighttime. This means the sun's light is blocked by the Earth, preventing it from reaching the moon.
So, even though the moon may still be visible in the sky after sunset, it's not getting any light from the sun at that time.