#3386 using synchronized to avoid multi-threading isseues during
closedown of env.