The electron is ejected from the nucleus and from the atom.
Once ejected it can lose energy in several ways:
a) Interaction with the electrons of another atom. The travelling electron interacts ('hits') an electron on another atom, knocking it out of the atom. As this atom is now has a hole where the electron used to be, when another (or the same) electron falls into the hole, energy is released as a photon (depending on the energy, it could be an X-ray, or it could be light, or low energy infra-red (heat)).
The electron that was knocked out now has some of the energy of the original beta electron, and could potentially go and cause further ionisations. Eventually, all the electrons lose so much energy that they can't cause any more ionisations, and the remainder of the energy is dissipated as heat.
b) Interaction with the nucleus of another atom. The negative electron is attracted to the positive nucleus and if its normally straight path comes close to a nucleus the path will be bent. Accelerating (changing the direction of) an electron causes the electron to lose energy by emitting photons. If the nucleus is very strongly positive, or if the electron comes very close, these photons can have X-ray energies. This process is called bremsstrahlung. In general, the electron isn't allowed into the nucleus itself, and will tend to bounce (scatter) off it.
High energy beta emitting radioisotopes should therefore be shielded with low atomic number materials (aluminium, polythene). As the high positive charged nuclei of high atomic number materials like lead, cause many more high energy X-rays to be emitted.