set shutdown flag to true in stop() method before waiting for empty queue

After a quiet period the batch size and queue size might be empty thus ending the while loop but some new message had a chance to be added to the queue before the flag was set. 
Thus calling the stop() method from a different thread than the one calling process was not threadsafe!
Merge pull request #2 from maximecaron/patch-1

set shutdown flag to true in stop() method before waiting for empty queu...