implemented graceful shutdown and fixed issue with bdb driver sharing handles across forks