Stars can loose mass in a variety of ways. Our own Sun is steadily ejecting a 'wind' of particles at a rate of one 100 trillionth of its total mass every year. At the present rate, this will not amount to more than perhaps the mass of the Earth over the life time of the Sun. But as stars age, this ejection rate increases greatly and can reach as high as the mass of a star like the Sun in a million years or less. The star is evolving through its so-called red giant phase enroute to producing a planetary nebula, or for more massive stars, even a super nova.
Stars in binary star systems can exchange mass between themselves over the course of millions of years which can change the evolution of the member stars. If one star expands to become a red giant, some of its material can fall onto the companion star causing it to gain mass and evolve more rapidly as a massive star.
The most drastic way a star can loose mass is via a supernova detonation. In a matter of seconds, as much as 50 percent of the mass of the star can be explosively ejected.