Drain input queues when changing state
Merge pull request #971 from mkienenb/PR-drain-input-queue-on-state-switch

Drain input queues when changing state