Nginx will not shutdown because the cleanup timer always just recreates the timer every time the handler is called. The handler should check if nginx is exiting and not set the timer.
Do not add the timer if nginx is exiting
Use uri from the authorization header
Auth response header URI must be the same as the http request URI
Please pull your patch to well-maintained branch https://github.com/chazmcgarvey/nginx-http-auth-digest.