This is the section 17 of munkre topology...example 5 ???
EXAMPLE 5. Consider the following subset of the real line: $Y = [0, 1] ∪ (2, 3),$ in the subspace topology. In this space, the set $[0, 1]$ is open, since it is the intersection of the open set $(−1/2, 3/2)$ of $R$ with $Y$ . Similarly, $(2, 3)$ is open as a subset of $ Y$ ; it is even open as a subset of R. Since $[0, 1] $and $(2, 3)$ are complements in Y of each other, we conclude that both $[0, 1]$ and $(2, 3)$ are closed as subsets of $Y $.
Now my question is that why $(2,3)$ is closed subset 0f $Y$ ???
This is exactly because of the comment in your question: "Since $[0,1]$ and $(2,3)$ are complements in Y of each other".
Sometimes we call such sets "clopen" sets.
Basically, the concept of "open" and "closed" are not exclusive, "closed set" is defined as a sets whose complement set is "open", and thus you could find a set that is open and closed at the same time.