Fixed infinite loop on hitting the stop button.