Ensure submod handler properly ends its thread

Previously, the submod handler didn't close its input or end its
thread. Now, it does.