Added coded to prevent the process and thread handles from being closed twice on cleanup.
Fixed memory leak in PAM authorization module