Detecting ends of residually finite groups in profinite completions