I have a question from Algebraic Geometry by Robin Hartshorne. My question is on the following proof:

Theorem. Let be a variety and be an affine variety. Let be the coordinate functions on . A map of sets is a morphism if and only if is a regular function on for each .

Proof

If is a morphism then the are regular functions. This is by the definition of a morphism.

Suppose the are regular. Let be any polynomial. Then is also regular on . Now because the closed sets of are defined by the vanishing of polynomial functions and because regular functions are continuous, takes closed sets to closed sets. So is continuous. Recall that regular functions on open subsets of are locally quotients of polynomials. Hence is regular where is a regular function on any open subset of . Therefore is a morphism.

I don't understand this sentence:

Now because the closed sets of are defined by the vanishing of polynomial functions and because regular functions are continuous, takes closed sets to closed sets.

How do we get takes closed sets to closed sets? I guess I just don't understand this sentence in the proof. Thank you.