The Messenger of Allah ﷺ used to pray Maghrib when the sun had set and disappeared behind the veil of the horizon.
أن رسول الله ﷺ كان يصلي المغرب إذا غربت الشمس، وتوارث بالحجاب.
Bukhari reported it in the Book of Prayer Times (561), and Muslim in the Book of Mosques (636), both through Yazid bin Abu Ubayd, from Salama bin Akwa, and he related the hadith. The wording given is Muslim's. Bukhari's wording is, "We used to pray Maghrib with the Prophet ﷺ when 'it disappeared behind the veil,'" and he did not mention "when the sun set," as an abridgment, because his saying "it disappeared behind the veil" indicates its setting.