Database isn't closed

Without this modification, the database is removed from the dbrmap
before it is tried to close.