debug: add memleak info to "make distcheck"

do --enable-valgrind to get better diagnostics in case of
memory leaks
testbench: "prevent" memleaks due to race

imdiag may not have enough time to properly terminate when the
shutdown request is made. Thus we give it a little headroom. Note
that this does not address a real issue inside the code - at most,
it looks like a memory leak, but one where the whole process is
immediately destructed. However, it is an annouance for the testbench.
Note that the race may still occur based on circumstances, but now
is much less likely.
Merge branch 'v7-stable'