Slightly modified to run under Windows & Msys/Cygwin
parametrised version of killOrphans