deal with socket closing too early