<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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()