hopefully fixed db closing problems