Fix socket closing under Windows.