Hz. Peygamber (sallallahu aleyhi ve sellem) remained at Arafat until after the sun had completely set, and then he departed for Muzdelife. This established the Sunnah of remaining at Arafat until sunset. The scholars differ on the ruling for a haci who departs before sunset and whether a penalty is required.
The Hanbali school, followed by Ibn Baz and Ibn Uthaymeen, holds that remaining at Arafat until sunset is wajib (farz), and leaving before sunset without returning requires a dam (sacrifice of a sheep). Their evidence is that Hz. Peygamber consistently remained until sunset and said: 'Take your rites from me.' If the haci returns to Arafat before sunset — even briefly — no penalty is due. Sheikh Ibn Baz emphasized that Hz. Peygamber's practice of staying until sunset is binding, not merely sunnet.
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 sunnet 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 haci left before sunset, as long as they were present at Arafat at some point after zawal. The Hac is not invalidated by early departure.