The Prophet (peace and blessings of Allaah be upon him) said: “The time for Maghrib lasts until the twilight has faded.”
i.e., the time for Maghrib starts immediately after the time for ‘Asr ends, which is when the sun sets, until the twilight or red afterglow has faded. When the red afterglow has disappeared from the sky, the time for Maghrib ends and the time for ‘Isha’ begins. Defining this time by the clock varies according to the season. When you see that the red afterglow has disappeared from the horizon, this is a sign that the time for Maghrib has ended.