Fix mac os crash on rescan
The crash is caused by that the hid_init(detection thread) and hid_exit (main thread) run on different threads.
So I moved the hid_init in the main thread.
Resolves #2153 (closed) #2431 (closed) #3055 (closed) #3200 (closed) #3708 (closed)