Cancelling the threads are trouble, stop them manually

Don't rely on pthread_cancel, as we may free the timer, before the
thread is actually cancelled. This leads to segmenetation faults. Stop
the threads manually instead.