A closed environment is an environment in which there is no energy transfer to the medium outside the system considered. In this case, we have into account the two balls colliding. In the case of deep space, there is no medium in which the energy of the collision can be transferred, and therefore it is a closed environment.