All metric spaces are both open and closed as subsets of themselves. The most general definition of "topology" requires that it include both the entire space and the empty set and other definitions (for metric spaces for example) satisfy that. A set is closed if and only if its complement is open. Since the complement of the entire space is the empty set, and the empty set is open, the entire space is also closed.
Those are the only sets that are both open and closed ("clopen") if and only if the space is connected.
For example, if X= (-\infty, -1] U [1, \infty), the real numbers with the open interval (-1, 1) removed, with the "usual" metric |x- y|, then X is not connected and X itself is both open and closed, the empty set is both open and closed, (-\infty, -1] is both open and closed, and [1, \infty) is both open and closed.