In a metric space, if a set is compact, then it is closed: improving proof 
Let $(M,d)$ be a metric space. If $K\subset M$ is compact, then it is closed (and bounded).

Proof Let's see that $M\setminus K$ is open. Let $x\in K$ $$\exists \varepsilon_1 (x), \varepsilon_2(x) \text{ so that } B(x, \varepsilon_1(x))\cap B(y,\varepsilon_2(x)) = \emptyset$$
then $K \subset \cup_{x\in K} B(x, \varepsilon_1(x))$ and, since $K$ is compact $\exists N \in \mathbb N \; \exists x_1,...,x_N \in K$ s.t.
$$ K\subset \bigcup_{i=1}^N B(x_i, \varepsilon_1(x_i)) $$
let $r = \min\{\varepsilon_2(x), i = 1,...,N \} > 0$, then
$$ B(y,r)\cap B(x_i, \varepsilon_1(x_i)) = \emptyset \quad\forall i = 1,...,N $$
therefore $B(y,r)\subset M\setminus K$ and $K$ is closed.
Question Why uses $\varepsilon_1(x)$ and $\varepsilon_2(x)$? If we consider, in $\mathbb R$ the interval $[0,1]$ it can't be covered using open balls without covering elements of $\mathbb{R}\setminus[0,1]$, so what happens when choosing $r$? Am I missing something?
Thanks in advance.
 A: I think this proof might be a little clearer in its more general setting. That is if $X$ is a Hausdorff space and $Y \subset X$ is compact then $Y$ is closed. We call a space Hausdorff if for any two distinct points $x,y \in X$ there exists open neighborhoods $U,V \subset X$ so that $x \in U$ and $y \in V$ and $U \cap V =\emptyset$. It's clear that metric spaces are Hausdorff because you can separate two points taking balls around each half the distance between the two. Concretely we take $r=d(x,y)/2$ then have $U=B(x,r)$ and $V=B(y,r)$. 
Now let $Y \subset X$ be compact. Pick $y \in X \setminus Y$. For each $x \in Y$ by the Hausdorff property we can find open sets $U_x$ and $V_x$ so that $x \in U_x$, $y \in V_x$ and $U_x \cap V_x=\emptyset$. Now it follows that
$$Y \subset \bigcup_{x \in Y} U_x,$$
since $Y$ is compact there exists some $x_1,\dots,x_n$ such that $U_{x_1},\dots,U_{x_n}$ covers $Y$. Then set $V=V_{x_1} \cap \cdots \cap V_{x_n}$ it follows that $V$ is open and contains $y$ but $U_{x_i} \cap V_{x_i}=\emptyset$. Since $Y$ is contained in the union of the $U_{x_i}$ we have that
$$Y \cap V = \emptyset.$$
Thereby around every point $y \in X \setminus Y$ we can find an open set contained in $X \setminus Y$. It follows that $Y$ is closed since $X \setminus Y$ is open. 
A: I prefer the proof using limit point compactness, which is equivalent to cover compactness in metric spaces:
Definition: limit point compact
Let $X$ be a metric space. A set $A \subset X$ is limit point compact if every infinite subset of $A$ has a limit point in $A$.
How do we use this to show closed? Well, a limit point of $A$ (if one exists) has a sequence in $A$ converging to that point by definition. The set of all points in such a sequence would be an infinite set in $A$. Can you finish?
A: I'm guessing from your question that you've mentally switched the order of the quantifiers. Your argument shows that $\epsilon_1(x)$ cannot be chosen independently of $y$, but it doesn't have to be. Given $y$, both $\epsilon_1(x)$ and $\epsilon_2(x)$ can be chosen small enough that there's no overlap; but the union of the balls with radii $\epsilon_1(x)$ will contain other points in $K\setminus M$ closer to $K$ than $y$, for which $\epsilon_1(x)$ will have to be chosen smaller.
