Ensure that the shutdown is on the correct thread