Turn on the bathroom exhaust fan, then get up on the roof. Place your hand against the top of the exposed pipes exiting the roof, feeling for the one exhausting air. Mark this pipe with an "X", using the pencil.
Go into the attic. Place your ear against the pipes running from the floor through the ceiling. When you find the pipe that has air rushing through it, mark it an "X". Turn off the bathroom exhaust fan.
Return to the roof. Shake a can of fast-acting spray foam insulation for 10 seconds and spray the foam into the pipe's hole. Stop spraying once the hole is filled. Let the foam set for the amount of time specified in the instructions, then spray a second application of foam into the hole.
Return to the attic. Use the hacksaw to cut through the top end of the pipe that has an "X" on it, cutting about 5 inches below the ceiling of the attic. Cut through the bottom of the pipe, about 5 inches up from the floor.
Pull the pipe off the cut ends and place it away. Shake the can of spray foam insulation for 10 seconds and spray the foam into the top of the pipe protruding through the roof. Stop spraying once the hole is filled. Let the foam set for the amount of time specified in the instructions.