Do the "physicist common knowledge" that "solenoidal vector fields have closed integral curves" have any mathematical foundation? I remember having heard some physicist claiming that the integral curves of the magnetic field have to be closed, or "closed at $\infty$", due to the fact that the magnetic field is solenoidal, i.e., that its divergence is zero. I'm looking for a mathematical proof of this fact. Here's a (possible) mathematical formulation of the problem.
Suppose $F:\mathbb{R}^3 \to \mathbb{R}^3$ is a $C^1$ solenoidal (i.e., such that $\mathrm{div}(F) = 0$) vector field. Let $I$ be an open interval and suppose that $\gamma:I\to\mathbb{R}^3$ is an integral curve for $F$, i.e., $\gamma$ is a $C^1$ curve such that $\forall t\in I, \gamma'(t)=F\big(\gamma(t)\big)$. Suppose that $(\gamma,I)$ is maximal, in the sense that if $J$ is another open interval such that $I \subset J$ and $\delta: J \to \mathbb{R}^3$ is another $C^1$ curve such that $\forall t\in J, \delta'(t)=F\big(\delta(t)\big)$ and $\delta \mid_I = \gamma$, then it holds that $J=I$. Suppose that $I = (a,b)$, where $-\infty \le a < b \le +\infty$.
Is it true that one of the following must hold:

*

*$\lim_{t \to a} \|\gamma(t)\| = \lim_{t \to b} \|\gamma(t)\| = +\infty $ (i.e., the curve is closed at $\infty$),

*$\exists c\in(a,b), \exists d\in(c,b), \gamma(c) = \gamma(d)$ (i.e., the curve is closed)?

Any proof (or pointer to a mathematical proof in the literature) or counterexample is very welcome.
 A: It's better to start the problem in terms of vectors rather than parametrizations. Take the planar* case of a magnetic field restricted to the $xy$ plane $\vec{B} = (B_x,B_y,0)$. The (up to a minus sign) planar* vector field perpendicular to it at every point (i.e. "pierces" the field lines everywhere) is given by $\vec{A} = (-B_y,B_x,0)$. This immediately gives us
$$\implies \nabla\times\vec{A} = (0,0,\partial_xB_x+\partial_yB_y) = (0,0,\nabla\cdot\vec{B}) = \vec{0}$$
which means $\vec{A}$ is a conservative vector field*. This means that the field lines of $\vec{B}$ represent the level curves of a continuous function, which are always closed.

There are quite a few asterisks here, namely a purely planar field is not physical, how does one choose a unique (up to a direction of flow) orthogonal field in 3 dimensions, and what about topologically interesting situations created by nonstatic fields or fields in interesting media where $\vec{A}$ would not be conservative even in the $2$D case (such as topological insulators)?
To address these in order:
The purely planar field makes the math easy and does extend to three dimensions with some help from differential geometry. We can insert a parametrization of the field lines ($\vec{B}$) at this stage and talk about choosing the torsion-free component (i.e. orthogonal but still in the osculating plane) of the vector field as the orthogonal, conservative field of choice (the $\vec{A}$ in my example).
This would lead to level surfaces rather than level curves, but the magnetic field lines would still live on these surfaces. The direction to choose requires a more in depth analysis of the vector field as being a dipole field, and depends on the orientation of the dipole.
And well, anything goes if you play with your assumptions. Exotic nonlinear situations where Maxwell's equations don't apply can create different looking magnetic fields.
