Move the API_END macro call to the end of the close routine, leave the
end lable where it is, that way we don't stop processing on config
error, but error messages and other session information will be correct.