r18626: fix cleanup function to safely recover after interrupted test