Proving the Zero Set of a Continuous Function is Closed

Question: Let f be a continuous real function on a metric space X. Let Z(f) be the set of all such that f(p)=0. Prove that Z(f) is closed.

My Thoughts: This statement is obvious if all the zeroes f are disjoint. Z has no limit points, and thus contains them all, so Z is closed. I don't understand how to prove that Z is closed if Z contains an entire interval's worth of zeroes though.

Like, for instance, . This function I believe is continuous but has zeroes on the entire interval [-2,2]. How would I prove a function similar to this has a closed Z(f).

Are there any other cases I'm forgetting to consider?