Onryō (vengeful spirit, sometimes translated as wrathful spirit) are extremely malevolent and bloodthirsty spirits.
However, they have a set goal and –usually— will only harm those who have wronged them. Nonetheless, some powerful and angry Onryōs linger and continue hurting people even after they have achieved their revenge.
There are many examples of Onryō vengeance. One of them is the story of a samurai who promised his dying wife that he would never remarry. He breaks that promise soon after she dies, so she returns as a vengeful spirit and beheads his new wife.
In another story a woman dies of heartbreak and curses her most prized and beautiful kimono. She then returns from the grave to kill anyone who wears it.
There are also a few Onryō known to let the target of their vengeance live but then set out to destroy their lives.
The easiest way to get rid of an Onryō is to let it do whatever it wants. Once it has its revenge it will rest in peace and cause no further damage. You can also help the ghost by slaying its killer or giving its body a proper burial if that hasn’t been preformed.
To forcefully remove an Onryō you need a Buddhist priest to perform a special service destined for those who died unfortunate deaths (similar to an exorcism). Another method is to place a piece of paper whit holy Shinto writings containing the name of a Kami, on the ghost’s forehead. Likewise, you can prevent an Onryō from entering a house by sticking these papers on doors.
-Foster, M.D., 2009. Pandemonium and Parade: Japanese Monsters and the Culture of Yokai. Univ of California Press.