Close database. Fixes Ticket #118

To be tested. Use on your own risk.