improve cleanup of shell adaptor tmp files

This might improve performance on MacOS specifically.