close rl when an error is detected