Is it haram to pray Asr just a few minutes before Maghrib?
The best time to pray Asr is while the sun is still bright. Once the sun turns yellow, delaying Asr without a reason is disliked. However, the prayer is still valid until the sun sets.
The Prophet ﷺ said: “The time of ‘Asr Prayer comes to an end when the sun becomes yellow.” (Sahih Muslim. Book 5, Hadith 219)
He ﷺ also said: “Whoever catches one rak‘ah of ‘Asr before the sun sets has caught the prayer.” (Sahih al-Bukhari Book 9, Hadith 55)
So, praying Asr just before Maghrib is valid, but it is better not to delay it that much. If the sun sets before you start, the time is over, and the prayer must be made up.