Don't block forever so that we keep checking the stop flag.