core: Fix quitting from networks on shutdown
The previous implementation relied on processEvents() to let the
QUIT command be sent to the IRC server. However, processEvents()
does not guarantee that it processes all events (also in other
threads), and indeed, the previous approach was not reliable.
Fix this by waiting for the networks to emit the disconnected()
signal after requesting the quit. There already is a 10 second
timeout in case the IRC server does not close the socket within
a reasonable time, so rely on that. Also ensure that connect requests
are ignored during shutdown.
With the CoreSession requesting a clean shutdown, we no longer need
a similar handling in CoreNetwork's dtor, so remove this.
See also GH-203 and GH-207, which were previous attempts on getting
this right.