Check if directory exists before removing it. Refs #2958