fix Database close issue