pam_end() terminates use of the PAM library. On success, the contents of *pamh are no longer valid, and all memory associated with it is invalid.
Normally, pam_status is passed the value
PAM_SUCCESS, but in the event of an
unsuccessful service application, the appropriate PAM error
return value should be used.