stopping the thread on exceptions