Close sockets before joining to avoid an annoying timeout.