CDB-2073 Fix connection closing