diff --git a/lib/index.js b/lib/index.js index 02c01636..5a395ede 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,11 +25,12 @@ PG.prototype.end = function() { var pool = self.pools.all[key]; delete self.pools.all[key]; pool.drain(function() { - pool.destroyAllNow(); - count--; - if(count === 0) { - self.emit('ended'); - } + pool.destroyAllNow(function() { + count--; + if(count === 0) { + self.emit('ended'); + } + }); }); }); };