After thinking about it more, it's probably better to make this a daemon thread so that it won't hang the process if the thread is not finished yet when the process tries to exit.