shutdown threads before query db