Apply fix for LUCENE-5330 pruning the IndexWriter queue to get rid of pending event

Closes #4093