Shut down db connection on the proper thread