added stop recording on error