Where does the photon's energy come from in X-ray bremsstrahlung?

In an X-ray tube, bremsstrahlung is generated by accelerating electrons toward a target metal. As a photon is emitted, something loses energy. I suppose that the target metal remains fixed and is re-used -- does this mean that the electron loses kinetic energy? Could it lose all of its energy and start to orbit the target atom?

-
bremsstrahlung = "braking radiation" –  user2963 Jan 21 '12 at 13:56