This happens every time me and the wife go out to dinner with our sisters. They finish eating and sit around talking about stuff and torture me sometimes 2 hrs past when they have finished. They know I don’t like to sit around that long after we eat but I’m told it’s polite to socialize with them cause we haven’t seen them for awhile.
It is socially more acceptable and polite to stay.
Do they contribute to you or your spouse in some way? If not, then you can definitely just say your goodbyes. Especially since it's family or if it was good friends' of your wife, then I'd say plan an activity that you like to do but give them the option to be included with you. There's definitely a balance. If they do things for you, you need to sacrifice in return. If they don't do anything for you, then you can politely say you need to get leave. Have your own way to leave and your wife and can stay and enjoy her time with them. But always keep your door open. Just in your own way. Sometimes, you'd rather just relax alone but since you don't see them that often anyway, if they don't do anything for you to help you or your wife out, then have kind of an "exit" plan.