At shutdown, do not attempt to use the DB conn if not opened.
Fixed keeping DB conn open in the process doing shutdown
Fixed bug in memory handling (size and init)