Several shutdown-related fixes
Several shutdown-related fixes

* do not let vnThreadsRunning[1] go negative
* do not perform locking operations while vnThreadsRunning[1] is decreased
* check vnThreadsRunning[1] at exit

wastholm/bitcoin,wastholm/bitcoin,wastholm/bitcoin,wastholm/bitcoin,wastholm/bitcoin,wastholm/bitcoin