Rejection of surface background in thermal detectors