scanner: catch SIGINT in the main loop
also split main function into an extra main_loop function to be able to stop the threads after they have started. Also check end event in the mean loop and before starting to measure a new relay. Fixes bug #28869. Bugfix v0.1.0.