Ensure history database is closed in test

Hopefully fixes the last Windows test on Python 3.3