Is the union of a compact and the relatively compact components of its complementary in a manifold compact? I was thinking of a way to prove this and I realised that for my approach the lemma from the title would be useful, and it´s an interesting question on its own. Obviously it is true if the manifold is compact or $\mathbb{R}^n$, but I don´t see it in general. This is the precise question:
Let $M$ be a connected manifold and $X$ a compact inside it, then is the union of $X$ and all the relatively compact components of $M\setminus X$ compact?
P.S. I already asked this question in MSE a few days ago, but after asking a few people I thought it could be more appropiate for MO.
 A: I believe your set is indeed compact. Its complement is the collection of points $x$ such that there exists a continuous curve $\gamma^x:\mathbb R_+\to M$ such that

*

*$\gamma^x(0)=x$;

*$\gamma^x$ leaves every compact set;

*the image of $\gamma^x$ stays outside $X$.

According to this point of view, it is clear that this set is open, and decreasing in $X$. It will suffice to show that your set is compact for some $X'\supset X$ large enough.
Let $X'\supset X$ be a compact submanifold with boundary in $M$ of maximal dimension (for instance, embed $M$ as a closed set of $\mathbb R^n$, and consider the intersection with a large close ball; by Sard's lemma it is a manifold with boundary most of the time). I claim that $M\setminus X'$ only has finitely many components, which will conclude. Every point of $\partial X'$ admits a neighbourhood that intersects exactly one connected component of $M\setminus X'$ (because locally $X'$ is just a half-space). By compactness, we can find an open neighbourhood of $\partial X'$ that intersects only finitely many components, and by connectedness of $M$ every such component intersects every neighbourhood of $\partial X'$, so those are finitely many as advertised.
A: Actually, there is an elementary proof of this. I will imitate the one given in O.Forster Lectures on Riemann Surfaces. We assume $M$ is connected. Let $Y$ be equal to the union of $X$ with all the relatively compact components of $M \setminus X$
Let $U$ be a relatively compact, open subset containing $X$ and let $C_j$, $j \in J$ be the connected components of $M \smallsetminus X$. Let $bU$ be the boundary of $U$, which is compact and disjoint from $X$.

*

*Claim 1. Every $C_j$ meets $U$: If $C_j \subset M \setminus U$, its closure in $M$ is also contained in $M \setminus U$, but $C_j$ is a connected component of $M \setminus U$ so $C_j = \overline{C_j}$ which conttradicts connectedness of $M$.

*Claim 2. Only finitely many $C_j$ intersects $bU$: This is because $bU$ is compact and the $C_j$ are open and disjoint, anc cover $bU$.

*Claim 3. $Y$ is closed: Let $J_0$ consist of the indices corresponding to relatively compact components. Then $M \setminus Y = \bigcup_{j \not \in J_0} C_j$, which is open.

By Claim 2, we can find $j_1, \ldots , j_k \in J_0$ be such that $C_{j_i}$ intersects $bU$. Then , by Claim 1 again, any other $C_j$ is contained in $U$. Therefore,
$$ Y \subset U \cup C_{j_1} \cup \ldots \cup C_{j_k}$$
RHS is relatively compact by the choice of $U$ and the $j_i$, and LHS is closed by Claim 3, so LHS is compact too.
