close the body after an error check