I'm having troubles accepting that the magnetic flux through a closed surface is always zero. I understand the fact that no magnetic monopoles exist , therefore all the 'lines' of magnetic flux that exit the surface must enter back, but if the surface is irregular, the angle the field creates with the normal to the surface would be different in the 2 cases, therefore making their dot product different and the flux is not going to be zero, also the value of the magnetic field that exits the surface could differ from the value of the magnetic field that enters.
What is the factor that makes the flux zero? Am I missing some details?