Simple guard against pid not existing.

As per #6679.