The most correct opinion is that staying in‘Arafah until the sun sets is obligatory,
because the Prophet(blessings and peace of Allah be upon him) did not leave before the sun set, and if it were permissible he would have left before the sun set, because then it is still daytime and is easier for people.