If I understand you correctly, this PVC pipe comes out of the main drain line from a tee or wye joint and at this time serves no function except to gather debris that then clogs the drain. If that is the case, dig it out as deep as possible, clear to the connection to main drain preferably. Then cut it off as square as possible leaving about a 2" stub. Then cement a PVC cap on the stub. Be sure that this is PVC and not ABS or old transite pipe. If it is ABS do the same as above except use and ABS cap and cement. If it's transite, I'm not sure what would cap it short of a no-hub connector, a short length of PCV with a cap. I wouldn't leave any more than necessary out of the main line.