A mechanism for magnetic field stochastization and energy release during an edge pedestal collapse