Add support for interrupting the thread.