BUGFIX: All database threads should be properly closed now.