adding shutdown
make RAII also handle the locking, since its cleaner, and confuses the env class less