open/close the DB gracefully