Fix connection closing