Using Ubuntu 18.04.2 LTS, with up-to-date, self-compiled master.
When I run
`./bitcoind -regtest -whitebind=bla`
I expect a clean shutdown with `Error: Cannot resolve -whitebind address: 'bla'`.
However sometimes my node doesn't stop and freezes (shutdown never finishes). 
This happens ~30% of the time for me, both on testnet and regtest. 

I believe that this is because `torControlThread.join();` never returns if it the thread is stopped right after its creation - it is started right before the whitebind part in `AppInitMain()`. If I insert a sleep before whitebind parameters are processed in Step 12 of `AppInitMain()` (or if I just disable the TorControl thread) the error does not occur.

Could someone try to reproduce? I encountered this testing #16248, but it is not restricted to this branch.

for (const std::string &s : reply.lines) {
                LogPrintf("    %s\n", SanitizeString(s));
            }
            return;
        }
        service = LookupNumeric(std::string(service_id+".onion").c_str(), Params().GetDefaultPort());
        LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString());
        if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) {
            LogPrint(BCLog::TOR, "tor: Cached service private key to %s\n", GetPrivateKeyFile().string());
        } else {
            LogPrintf("tor: Error writing service private key to %s\n", GetPrivateKeyFile().string());
        }
        AddLocal(service, LOCAL_MANUAL);
        
    } else if (reply.code == 510) { 
        LogPrintf("tor: Add onion failed with unrecognized command (You probably need to upgrade Tor)\n");
    } else {
        LogPrintf("tor: Add onion failed; error code %d\n", reply.code);
    }
}
void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& reply)
{
    if (reply.code == 250) {
        LogPrint(BCLog::TOR, "tor: Authentication successful\n");
        
        
        if (gArgs.GetArg("-onion", "") == "") {
            CService resolved(LookupNumeric("127.0.0.1", 9050));
            proxyType addrOnion = proxyType(resolved, true);
            SetProxy(NET_ONION, addrOnion);