This is probably not a race, but it smells like one. I would suggest getting the client into a temp var and then checking for null and closing if not.