Change shutdown hook priority

Fixes #5860