Refactoring worker to be shutdown after a configurable number of requests