Fix graceful shutdown logic

Resolve bug #1081367
Merge pull request #5148 from ironcladlou/stg/graceful-stop-fix

Merged by openshift-bot