infinite loop fix (when stopped becames true)

Even after we check if "stopped" true or false, it can become true from another thread when we are in "while" loop, what, in my case, caused infinite loop and heavy cpu load later. We need to check it every time in while loop condition.