Terahertz emission induced by optical beating in nanometer-length field-effect transistors