Topological spaces in which every proper closed subset is compact Let $X$ be a topological space.  It is a well-known result that, if $X$ is compact, then every proper closed subset $Y \subset X$ is compact.  Out of curiosity, I would like to explore the converse of this statement:

Let $X$ be a topological space with the property that every proper closed subset is compact.  Is $X$ itself compact?

Of course, this question is only interesting when $X$ is infinite.  We can further restrict ourselves to spaces that have infinitely many open sets since every closed set, and indeed the space itself, would be compact otherwise.  If this result is false in general, what hypotheses can be added to make it so?
Should this not hold, I'm interested in finding concrete examples of when it does.  For instance, we can take any infinite set endowed with the cofinite topology, which works because every closed set is finite and thus compact, and the space itself would be compact.  Another example is an interval $[a, b] \subset \mathbb{R}$, wherein closed subsets of this are closed and bounded in $\mathbb{R}$; as such, they are compact per Heine-Borel.

Update:  Zardo's answer reveals that such a topological space is indeed compact. For further discussion on the finite intersection property and its relevance to compactness, see Munkres' Topology: Chapter $3$, theorem $26.9$.
 A: I think that the most interesting examples of this are infinite topological spaces $X$ such that every proper closed subset is finite.  Such a space trivially has the property you mention, but is compact for less trivial reasons.
One nice example is $X=\mathbb{N}$, with the nonempty open sets $U_n = \{k \mid k\geq n\}$.
Note that this space is an inverse limit of finite topological spaces.  In general, an inverse limit of finite topological spaces is compact.

Here is another nice example!  Let $R$ be a commutative ring with unity, and $I\subset R$ an ideal.  For simplicity, assume that $R$ is reduced.  Consider the topological space $X = \operatorname{Spec} R \setminus V(I)$ of prime ideals of $R$ not containing $I$.
Suppose that every proper closed subspace of $X$ is compact.  This is equivalent to the condition that $V(J)\setminus V(I)$ is compact for each ideal $J$ with $IJ\neq 0$.
Unraveling this, our condition is that $\overline{I}$ is finitely generated in $R/J$ for all ideals $J$ with $IJ\neq 0$.  And the conclusion is that $I$ is itself finitely generated.
Indeed, we can take any nonzero $x\in I$.  Then $I\cdot(x)\neq 0$, and if $\overline{I}$ is finitely generated in $R/(x)$, we can lift generators to $R$, and throw in $x$ to get a set of generators for $I$.
A: Assume that $X$ is not compact. Then there is a family $\{A_i\}_i$ of closed subsets with the finite intersection property such that $\bigcap_i A_i = \emptyset$. Thus, there exists an $j$ with $A_j \neq X$. Then $A_j$ is a proper closed subset of $X$ but it is not compact, since the family $\{A_i \cap A_j \}_i$ has the finite intersection property and $\bigcap (A_j \cap A_i) = \emptyset$.
