Using pijyoi's patch for connection close.