A set, in a metric space, is "open" if and only if it contains none of its boundary points. If I am correct in interpreting the "dashed" boundary on the second square as meaning that those points are not in the set, then that set is open.
A set, in a metric space, is "closed" if and only if it contains all of its boundary points. If I am correct in interpreting the "solid" boundary on the first and third sets as meaning that those points are in the set, then that set is closed.
Of course, if a set contains some but not all of its boundary points then it is neither open nor closed.
It is even possible for a set to be both open and closed if it has no boundary points. In $\mathbb{R}^2$, the only such sets are the empty set and $\mathbb{R}^2$ itself.
The topologies with this property are precisely the ones that are derived from partitions of the underlying set $X$.
Specifically, let $\mathcal{P}=\{X_i\}_{i\in I}$ be a partition of $X$, and let $\tau$ be the collection of sets of the form $\cup_{i\in I_0}X_i$ for $I_0\subseteq I$. Then $\tau$ is a topology: the empty set corresponds to $I_0=\varnothing$, the set $X$ to $I_0=I$; the union of such sets corresponds to the family indexed by the union of indices, and the intersection to the intersection of the indices. Moreover, the complement of the set corresponding to $I_0$ is the set corresponding to $I-I_0$. Thus, $\tau$ has the desired property.
Now let $\tau$ be any topology on $X$ with the desired property. Define an equivalence relation on $X$ by letting $x\sim y$ if and only if for every $A\in \tau$, $x\in A$ if and only if $y\in A$. Trivially, this is an equivalence relation, and so induces a partition on $X$. I claim that $\tau$ is in fact, the topology induced by this partition as above.
Indeed, if $A\in \tau$, then $A=\cup_{x\in A}[x]$, where $[x]$ is the equivalence class of $x$. Trivially $A$ is contained in the right hand side, and if $y\in[x]$, then since $x\in A$ then $y\in A$, so we have equality.
Now, conversely, let $x\in X$ and look at $[x]$. I claim that $X-[x]$ lies in $\tau$. So see this, let $z\in X-[x]$. Then since $z\notin [x]$, there exists an open set $A_z\in \tau$ such that $z\in A_z$ but $x\notin A_z$ (and hence, $[x]\cap A_z=\varnothing$). Now, $\cup_{z\notin[x]}A_z$ is an open set, contains every element of $X-[x]$, and intersects $[x]$ trivially because each element in the union does. That is, this open set is $A-[x]$; but since the complement of every open set is open, and $A-[x]$ is open, then $[x]$ is open. Thus, $[x]\in\tau$.
We have then proven that every element of the partition induced by $\sim$ is open, and that every open set is a union of such elements of the partition. That is, the open sets are precisely the unions of elements of the partition $X/\sim$.
Added. The equivalence relation given in the second part can be defined in any topology, of course; and the proof that every open set is a union of equivalence classes and that the complement of an equivalence class is open, always hold. The only place where we used the hypothesis that all open sets are closed was to conclude the equivalence class itself was open. For example, in the standard topology for $\mathbb{R}$, the equivalence relation is the trivial one.
Best Answer
Nobody knows if the set of all reciprocals of Mersenne primes is closed. Or take the set of all reciprocals of odd perfect numbers; it is conjectured that it's open, there is a weaker conjecture that it's closed, but nobody knows.