Fixed closeConnection order.