Add function to terminate recording.