Why is this curve automatic closed?
A spline created by lightning_curve.splines.new('BEZIER') already has 1 vertex.
So when you add Bezline.bezier_points.add(len(coords)), the spline now has 5 vertices.
When looping:
for i, coord in enumerate(coords):
        x,y,z = coord
        Bezline.bezier_points[i].co = (x, y, z)

you're setting the coordinates of the 4 first and the last stays at (0, 0, 0), which makes the spline appear as closed.