Fix connection close deadlock