LearnBoost/kue — pull request #377 by vhain (2014-07-30 06:44:25+00:00)
Title: emit event 'job failed attempt' after job successfully updated

If we do `queue.shutdown` like below as written in document:
``` javascript
var queue = require('kue').createQueue();

process.once( 'SIGTERM', function ( sig ) {
queue.shutdown(function(err) {
console.log( 'Kue is shut down.', err||'' );
process.exit( 0 );
}, 5000 );
});
```

`queue.shutdown` will listens for event `'job failed attempt'` and calls callback function of `queue.shutdown`, which will eventually call `process.exit`.

Therefore, `'job failed attempt'` should be emitted **AFTER** job status update finishes (delay or inactive).

Otherwise, job requiring attempt can be stuck on failed status.