The escape of Lyman continuum (LyC) photons from galaxies into the intergalactic medium is arguably the most uncertain parameter in models of the epoch of reionization. An underlying but less studied parameter is the escape of LyC from GMCs where stars are born. We report a large set of simulations of star cluster formation from giant molecular clouds (GMCs) of various masses and densities, using a state-of-the-art radiation-magneto-hydrodynamic code RAMSES-RT. We consistently simulated the formation of individual massive stars and their photoionization feedback. The mass distribution of the sink particles (stars) in our simulations agrees with the observed core mass function extremely well, further validating the correctness of the treatment of radiation feedback from O/B stars. We find that photoionization is extremely efficiently at destructing the GMC: the cloud is destroyed by the expansion of HII regions in a few GMC crossing time of a wave at a speed of ~10 km/s, the sound speed in a typical HII regions. As an HII region expands due to the pressure gradient in the edge, it wipes out the gas and flattens the density contrast, quenching the star formation. We further post-processed the set of simulations to calculate the escape of LyC from individual stars, taking into account neutral hydrogen column density and dust extinction in all directions in the sky, and this is averaged over all stars and over their lifetimes to get a LyC escape fraction, fesc, from a GMC. This is the first work where the escape of LyC photons is calculated from self-consistently simulated O/B stars. We find that fesc decreases with increasing mass and with decreasing initial density of the GMC. GMCs with densities typical of local star formation regions have negligible fesc (below 0.07). We explained this trend with a simple model where two timescales are compared: the star formation timescale and the lifetime of the dominating UV source. The model is very successful at predicting the results from simulation.