Vector fields $X$ and $Y$ commute on a closed set $K$. Do there exist commuting $\tilde X,\tilde Y$ with $\tilde X=X$ and $\tilde Y=Y$ on $K$? I have a nice research idea whose proof hinges on the following question

Suppose $X_p$ and $Y_p$ are vector fields in $\mathbb{R}^3$ with $[X,Y]_p=0$ for all $p$ in some closed set $K\subset\mathbb{R}^3$. For each point in $p\in K$, does there a neighborhood $U$ of $p$ and a two dimensional foliation $\mathcal{F}$ on $U$ with the property that $T_qL_q=\operatorname{span}(X_q,Y_q)$ for each $q\in U\cap K$? Here $L_q$ denotes the leaf of $\mathcal{F}$ through $q$.

At a first glance, I thought this was probably true: after all, if such a foliation existed, then the vector fields must commute on $K$. But the more I try and prove it, the more I am having second thoughts on whether this is true.
My naïve attempt at a proof involves mimicking the proof of the Frobenius theorem; i.e. my candidate for the foliation would be the coordinate change
$$
(t_1,t_2,t_3)\mapsto\theta_{t_1}\circ\psi_{t_2}(0,0,t_3),
$$
where $\theta_t$ and $\psi_t$ denote the flows of $X$ and $Y$ respectively, but the details get a little hairy when the vector fields don't always commute.
I imagine that this has been studied before, so I was hoping someone would know of a reference that studies this question. If this is not true in general, what additional hypotheses are required?
Any help would be greatly appreciated.
 A: 
The picture  above gives a counterexample to your hope. It is in dimension 2 but there is no problem to make it in any higher dimension. The commuting vector fields are red and blue, the compact is not simply connected and the “hole” is such that at the point $C$ the boundary curves coincide in jets.
The caption on the right (in red) says that if you go along the red vector field along the hole you may come to the other side in different times (say, left way is faster than the right way). If you have a commutative blue vector field which can be extended to a hole than it is not possible, since the blue vector field   connects  the left and the right ways.
The caption on the left (blue) says that the pushforward of the blue vector field from the bottom to the top along the orbits of the red vector field must not match, in general. Indeed, on the top the pushforward of the blue vector field along the flow of the red vector field in the right side may be twice the pushforward of  blue vector field along the flow of the read vector field in the left side, which is also not possible if the flow is extended.  Note that if vector field $v$ and $u$ commute, then for any constant $C$ the vector fields  $v$ and $Cu$ also commute
