Fix errors in threadtest3 tests caused by earlier tests neglecting to close database handles.