Fix connection closing: close connection in all cases