def final():
    """In case the program is cancelled or quit, we need to clean up the PulseIn
    helper process and also the message queue, this is called at exit to do so"""
    if DEBUG:
        print("Cleaning up message queues", queues)
        print("Cleaning up processes", procs)
    for q in queues:
        q.remove()
    for proc in procs:
        proc.terminate()
In case the program is cancelled or quit, we need to clean up the PulseIn
    helper process and also the message queue, this is called at exit to do so