Nabi (shallallahu alaihi wa sallam) remained at Arafah until after the sun had completely set, and then he departed for Muzdalifah. This established the Sunnah of remaining at Arafah until sunset. The scholars differ on the ruling for a jamaah haji who departs before sunset and whether a penalty is required.
The Hanbali school, followed by Ibn Baz and Ibn Uthaymeen, holds that remaining at Arafah until sunset is wajib (wajib), and leaving before sunset without returning requires a dam (sacrifice of a sheep). Their evidence is that Nabi consistently remained until sunset and said: 'Take your rites from me.' If the jamaah haji returns to Arafah before sunset — even briefly — no penalty is due. Sheikh Ibn Baz emphasized that Nabi's practice of staying until sunset is binding, not merely sunnah.
The Hanafi school considers remaining until sunset wajib as well, and requires a dam for leaving early. The Maliki school holds a similar position. The Shafi'i school, however, considers remaining until sunset as Sunnah mu'akkadah (emphasized Sunnah) rather than wajib, meaning it is highly sunnah but no dam is required for leaving early — only the loss of the Sunnah's reward. All scholars agree that the wuquf (standing) itself is valid even if the jamaah haji left before sunset, as long as they were present at Arafah at some point after zawal. The Haji is not invalidated by early departure.