def set_terminate_listeners(stream):
def stop(signum, frame):<EOL><INDENT>terminate(stream.listener)<EOL><DEDENT>signal.signal(signal.SIGINT, stop)<EOL>signal.signal(signal.SIGTERM, stop)<EOL>
Die on SIGTERM or SIGINT