Close database on completion.