finish authentication and implement query loop
run cleaner

 * fix problems with address in use
 * cancel connections when stopping daemon
 * don't error in that case