check if db was opened before closing it, once more