The ionization potentials of magnesium clusters (MgN, N = 7-56) are determined by doping ultracold helium nanodroplets (HeM, M ≈ 52 000) with Mg atoms. Inspecting the particle size distributions resulting from non-resonant, short-wavelength, single-photon ionization gives evidence that beyond a certain ensemble size, the developing foam structure undergoes a spontaneous collapse on the way to the laser interaction region. As a result, hot Mg clusters form in the relaxation process. The spontaneous collapse manifests in a substantial change in the size distributions, when recording mass spectra at wavelengths shorter than 272 nm. Tracing individual MgN signals as a function of laser photon energy allows extraction of size-specific ionization potentials, which for small clusters show a good agreement with results obtained from density functional theory simulations. The further development is compared to calculations based on the liquid drop model. However, even when quantum effects are included, the simple scaling law is not able to reproduce the development of the ionization potentials. The results suggest that small neutral magnesium clusters behave as non-metallic. The comparison to electron affinities and band gaps obtained from photoemission experiments on MgN- provides information on the charge state dependence of the non-metal-to-metal transition and properties like the Mulliken electron negativity.