Closed connected integral submanifold is maximal I'm having some problems to prove the following assertion:

Let $\mathscr{D}$ be an involutive distribution of dimension $k$ in a
  manifold $N$. Let $(M,\varphi)$ be a integral connected submanifold,
  such that $\varphi(M)\subseteq N$ is a closed subset. Show that $M$ is
  a maximal connected integral submanifold of $\mathscr{D}$ (a leaf,
  say).

I've tried using the local version of Frobenius Theorem (each involutive distribution is integrable and locally its integral connected submanifolds are slices). However, the problem talks of something that is rather global (?), and I can't manage to complete the idea. I'd thank any kind of help.
 A: My solution uses two main ingredients.
1) Frobenius theorem ensures complete integrability. Let $N$ be the ambient manifold for the distribution $\mathcal{D}$. Then for each $p \in N$, there is a cubical (its image in $\mathbb{R}^{n}$ is an open cube) coordinate chart $(U,(x^{1},\dots,x^{n}))$ containing $p$, such that for all $q \in U$,  $\mathcal{D}_{q} = span\{ \partial_{1}|_{q}, \dots, \partial_{k}|_{q} \}$. The slices $x^{k+1} = c^{k+1}$, $\dots$, $x^{n} = c^{n}$ then form embedded integral submanifolds of $\mathcal{D}$. These charts are called flat for $\mathcal{D}$.
2) Local structure of integral submanifolds: For every integral submanifold $M$ of $N$, and any chart flat for $\mathcal{D}$, the intersection $U \cap M$ is a countable disjoint union of open subsets of parallel $k$-dimensional slices of $U$, each of which is open in $M$ (in the "inner" topology of $M$) and embedded in $N$. 
Note that I identify immersed submanifold $M$ with its image in $N$ (to save letters).
Now to the actual proof of the statement. Let $M$ be any integral submanifold, and let $M \subseteq M'$ for some connected integral submanifold of the distribution $\mathcal{D}$. We will now prove that $M$ is both closed and open in $M'$:
i.) $M$ is closed in $M'$:
By assumption $M$ is closed in $N$, hence it is closed in the subspace topology of $M'$ and consequently also in the "inner" topology of $M'$. We conclude that $M$ is a closed subset of $M'$.
ii.) $M$ is open in $M'$:
First, find a flat chart $(U,(x^{1},\dots,x^{n}))$ for $\mathcal{D}$ containing the point $p$. By 2) above, this means that both $M \cap U$ and $M' \cap U$ are disjoint union of some open subsets (open in the subspace topology of the slices) of parallel $k$-dimensional slices. 
Let $S$ be the slice of $U$ containing $p$. As $M \subseteq M'$, from 2) we get the two open subsets $W,W' \subseteq S$, such that $M \cap S = W$ and $M' \cap S = W'$. As $W$ is open in $S$, it is also open in $W'$. But by 2) $W'$ is open in $M'$. This implies that $W$ is also open in $M'$. This statement is in fact quite subtle, using the fact that $W' \subseteq S$ with subspace topology is homeomorphic to the connected component of the open submanifold $M' \cap U \subseteq M'$. Note that by construction $W \subseteq M$.
To summarize, to every $p \in M$, we have found its neighborhood $W$ open in $M'$, such that $W \subseteq M.$ This proves that $M$ is open in $M'$.
As $M'$ is connected, we see that $M = M'$. If $M$ is assumed connected, we have just proved that it is a maximal connected integral submanifold. Q.E.D.
Observe that I have in fact proved a slightly stronger statement - any integral submanifold which is closed as a subset of $N$ and it is contained in some connected integral submanifold $M' \subseteq N$ must be necessarily the whole $M$'.
