When brakes are applied, each of the motors is reversed into an electric generator, turning the kinetic energy of the trolley into electric energy that is fed back to the wires and ultimately to  other vehicles.
Electric motors transform electrical energy into kinetic energy.