Fix closeConnection bug.