Database close

Fixing a bug that caused database sizes to grow on windows because the database was never being properly closed.