Attempt to fix a race condition in the connection close routine