Rework main thread path + quit implementation

Main thread now starts the bot, idles until a shutdown is requested,
then cleans up and shuts the bot down.