Stay home.
Sounds like I’m being sarcastic but I’m not. I don’t enjoy visiting homes other than close relatives.
Follow their cues. Some people are very particular about how things are done in their home, others are very laid back. Some want to "host," others welcome you to raid their refrigerator. Read the room and behave in a way that makes them feel comfortable, whatever that may be.
Never arrive early and never stay too long, especially late into the evening. Some people may like to wind down and turn in early. Take a little gift (wine, flowers or something seasonal) but never unrequested food for a meal. Offer to help clean up but never insist if the host(ess) declines. Put up with the pets, if the household has them. I really dislike animals all over me but I'd never insult the host(ess) by complaining.
The thing is, though, it all goes back to following cues. My now ex-best friend (ex for many reasons, not just this) simply could not do it. She had hard and fast "rules" that would end up causing more problems than they solved. Case in point, relevant to this particular one:Never arrive early and never stay too long, especially late into the evening.
"No wine? You must have the wrong address." *locks door*for example bring pepsi
What I would do, or not hesitate to do, in this case, is be the first one to leave, if I felt like going home. It doesn't mean anybody else has to.The thing is, though, it all goes back to following cues. My now ex-best friend (ex for many reasons, not just this) simply could not do it. She had hard and fast "rules" that would end up causing more problems than they solved. Case in point, relevant to this particular one:
A big group of us went to La Nouba for my birthday a few years ago. One girl in the group had some connections and arranged a VIP backstage tour and seating up by the lighting booth. It was a fabulous evening. Afterwards, we were standing around in the parking lot talking.
Now, my ex-best friend only knew me, my dad, and one other person in the group. Everyone else was old theater friends of mine and my dad's, whom we hadn't seen in a while (including the girl who made the arrangements).
At one point, one of the theater guys said something about needing to head home because he had work the next day. And then he kept right on chatting for another 20-30 minutes. That's just how it's done in that particular group. We all keep mentioning that we should probably go home, but nobody really wants to, and it's not a serious comment until someone actually starts heading for their car.
Well, my ex-best friend got furious with me. She started yelling at me, in front of the entire group, about how the guy had said he needed to leave and I kept him talking, and how dare I be so rude! Needless to say, it was a bit shocking to everyone, and really killed the mood.
So yeah, it's great to have rules like don't stay too late. But if you're in a big group of people who ALWAYS stay late, don't be that person trying to rush everyone along because in your mind, it's too late. Not saying you would do that, but just something for all of us to keep in mind.
Our best friends are very prolific hosts and we're often involved in their gatherings. We know them well enough to know that the DH starts his days before 5:00 am so he likes to be in bed before 10:00 pm. When we're part of a group there we're almost always the first to leave when the clock strikes 9:00 pm.; hopefully giving everybody else the hint but not compelling them. Our friends have said many times how much they appreciate this. 
Rule 1. Tis better to ask forgiveness than permission.
Rule 2. Never tell the truth when a good lie will do.
Rule 3. Find the good stuff, and Drink it. You may need to remember rules 1 and 2 here.
(Gasp) that was a $3,000 bottle of wine we were saving for a special occasion. Rule 1. Oh I'm sorry. Forgive us. Well this is a special occasion am I right? Rule 2. I didn't know that was expensive. But Honey just between you and me, we did you a favor. This stuff tasted worse than that crap you've been serving everyone.
Rule 4. A little dirt never hurt.
Rule 5. After Burping or farting, always say something like My Compliments to the chef or better out then in.
Rule 6. If there is a baby, always mention it looks like a mutual friend's husband. Hey Jim. Steve and Jan's baby looks like you. Lacking someone handy fall back on how it looks like the mail man.
Rule 7. Bwooooshie poopies Are always funnier in the neighbor's toilet.
Rule 8. When drunk, always puke in the bath tub and leave it there.
Rule 9. Take as much food home as you can. Rule 2. Your tupperware full of beans? Haven't seen it (Now you get to keep the tupperware bowl too but remember to hide it when you have a party and they're over.) Or Rule 2 again. I loved your tupperware bowl so much I bought one for myself.
Rule 10. Lick the plate. It tells the host you liked her food.