Detecting exhaustion of target material