Coherent Perfect Diffraction in Controlled Metagratings