This may not just be because of kids leaving, but also because of the transition. Longer playdates may actually make this harder - even now, my son has a hard time transitioning out of anything that lasts longer than 3 hours (and he's 12)
You might try having a visual timer of some sort, first of all, and also pulling him out of the room before they leave and letting the other kids leave on their own a few times - you can make excuses like "he's kind of tired" to smooth it over with them. I don't think it will stop the meltdown, but it might at least make it more private.
A social story about playdates and how they end might also be helpful - sort of a first, then, then with obvious markers about the end of the playdate, like "after snack, the playdate is over and your friends will go home. You can say goodbye and then watch a video"