Should probably store this instead of calling `getDatabase()` twice. Then I think you could do something like:

```JS
var database = this.getDatabase();
database && database.close();
```