Consider $x^3$ for example, at $x=0$ , the tangent line is also intersects the function. The tangent line passes through to the other side at the same point it is tangent to the function.
It got me wondering, why can't a vector field enter a closed surface (creating a negative flux) and get out tangent to the surface, with zero flux, leaving total of negative flux in contradiction to gauss's law.

The total flux is only zero when the vector field is divergence-free.
If your example vector field (a) is divergence-free and (b) can be extended to complete the diagram without introducing a region of positive flux, then indeed you would have a counter-example to Stokes's theorem. But you can prove that constructing such an example is impossible.
If your vector field (call it $v$) is divergence-free, then its 90-degree-counterclockwise rotation $v^{\perp}$ is curl-free, and so is the gradient of some function, $$v^{\perp} = \nabla f.$$ Let's think about what $f$ must look like to match your picture. We can set $f$, WLOG, to equal zero at the middle-left point on the boundary (where your first streamline enters the region). Let's imagine what happens to $f$ as we move clockwise around the boundary.
In the top-left part of your diagram, $f$ increases. This is because $v^{\perp} = \nabla f$ points to the upper-right, and is aligned with the direction of travel.
In the region where $v$ leaves the region parallel to the boundary, $v^{\perp}$ leaves perpendicular to the boundary. Therefore $\nabla f$ is perpendicular to the boundary and $f$ is constant along that part of the boundary.
So we have that $f$ started at $0$ in the middle-left, increased to some positive value as we moved towards the top of the region, and then didn't change as we moved along the right part of the boundary. Now by the time we finish winding around the boundary, and return to our starting point, $f$ must decrease back to zero. This means that $\nabla f$ must point to the right along the bottom portion of the boundary, and so $v$ must point down. In other words, any divergence-free completion of your vector field must have streamlines that exit through the bottom of the boundary, providing the positive flux required by Stokes's theorem.