Change debug logging to the debug-log option
Improve thread cleanup when there's an error connecting

Signed-off-by: zml2008 <zach@zachsthings.com>
Fix quit message being sent too late

Signed-off-by: zml2008 <zach@zachsthings.com>