Close directories after opening them.