Fix some Exceptions on shutdown by properly interrupting the thread