Your code looks fine, except the signal handler is not called because it has the wrong signature. Make it like this:
def programCleanup(signum, frame):
Quoting the docs (signal.signal()):
The handler is called with two arguments: the signal number and the current stack frame