fix database close bug