bugfix, race condition on close db