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.

void protocolinfo_cb(TorControlConnection& conn, const TorControlReply& reply);
    
    void connected_cb(TorControlConnection& conn);
    
    void disconnected_cb(TorControlConnection& conn);
    
    static void reconnect_cb(evutil_socket_t fd, short what, void *arg);
};
TorController::TorController(struct event_base* _base, const std::string& _target):
    base(_base),
    target(_target), conn(base), reconnect(true), reconnect_ev(0),
    reconnect_timeout(RECONNECT_TIMEOUT_START)
{
    reconnect_ev = event_new(base, -1, 0, reconnect_cb, this);
    if (!reconnect_ev)
        LogPrintf("tor: Failed to create event for reconnection: out of memory?\n");
    
    if (!conn.Connect(_target, std::bind(&TorController::connected_cb, this, std::placeholders::_1),
         std::bind(&TorController::disconnected_cb, this, std::placeholders::_1) )) {
        LogPrintf("tor: Initiating connection to Tor control port %s failed\n", _target);
    }
    
    std::pair<bool,std::string> pkf = ReadBinaryFile(GetPrivateKeyFile());
    if (pkf.first) {
        LogPrint(BCLog::TOR, "tor: Reading cached private key from %s\n", GetPrivateKeyFile().string());
        private_key = pkf.second;
    }
}
TorController::~TorController()