Hi
@Elder - it sounds like you have already been to your party by now, but here's some thoughts from me. You need to know that I'm a bit fluey at the moment and it's a bit of a brain dump, so I hope this makes sense. The rules may be different between the US and the UK too - we are a more generally introverted society than you are.
I think there's two angles on it - one is what etiquette and good manners prescribe, but the other is what you need yourself for your own equilibrium.
As far as etiquette is concerned, usually the only people to thank are the hosts or the organisers - those who have put in the work and the resources. I'd normally do this myself on leaving - but then it depends upon the manner of my leaving exactly how. If I go while the party is still progressing for some, then I'll put my coat on then go and interrupt the hosts to say thankyou and goodbye. The interruption is flagged and given legitimacy by my having my coat on, and I've never known anyone to mind the interruption.
Mind you, that's if I'm leaving at time that isn't a bit discordant with the event - if I'm leaving unexpectedly early while things are still in full swing then it depends on the nature of the event. For a big one it's only courtesy to let the host know, thank them and give some sort of explanation - otherwise they may well be left feeling your departure is a criticism. Of course it might be just that, but then you have to find a form of words that explains the situation. For a small event, it's more difficult - usually onset of a headache or tummy upset are stock examples of reasonable excuses.
If you are leaving when everyone else is going, it's usually pretty straightforward - the hosts will almost certainly be saying goodbye to everyone anyway and will be buried in everyone's thankyous.
If you don't get a chance to say thank you when you leave, for whatever reason, a thankyou card or email is a great follow up.
If you are leaving when there are still folks staying on, then it's courtesy too, and only natural to say goodbye to anyone you have spent considerable time with. I'm no great party butterfly and at office dos I always got together with a handful of old friends and we'd while away the event chatting. Oh I'd circulate too, but that would be my basecamp.
With that last thought, there is maybe another etiquette issue to think about. It's quite possible for a few introvert friends in a corner to lose track of time and find most of the others have gone - it really depends on the event, but it isn't good manners to keep your hosts out of their beds LOL. For me, this has only ever happened with folks I already know very well - I usually run out of nervous energy quickly and need to escape with less familiar people, or those of a type that isn't easy for me to get along with.
As far as what level of small-talk is correct on the way out, it depends so very much. It gives a warm glow if you not only thank your hosts but say a little about what you enjoyed and why, and maybe ask them question or two about the event. I'd avoid open-ended questions if you want to get away. If they want to linger and chat, then having your coat already on does tend to limit the conversation.
Very often there are tactics you can employ. For example if more extraverted folks are on the way out too, then they and the host are likely to block the doorway nattering - this happens a lot with the church groups I belong to. It's then usually easy to just call our a thank you very much, etc, and goodbye, and squeeze past them without breaking any protocols. Use this one quite a lot myself.
As far as your equilibrium goes, it really depends on how you react to intense social situations. For INFJs, it's not just the unbounded extraverting that's a problem in many events, but the sensory overload too from an environment with lots of people and noise. Even when I've enjoyed myself at the time, I can have a reaction after an event that leaves me a bit high, shaky and drained, and I have to give myself time to recover. I'm not sure how much this is similar for someone on the autism spectrum, but I think it's really important to manage it. If you can, latch onto a basecamp of familiar friends that you can return to and relax with in between more general socialising.
Another way is to offer the host practical help where appropriate - tidying up and washing glasses, bringing food out, serving drinks, shifting furniture around, showing people where to go in a more formal event, etc. This too gives you a chance to wind down a bit and gives a less demanding sort of social interaction. In a way, this too is a show of appreciation to the organisers, who will certainly give you some appreciation back in return.