Issue #4172 - Fixed empty priority queue state

Added check for empty queue. Fixes issue #4172