You can stop ghosts from visiting simply by placing their urn/headstone in a Sim's inventory (or by deleting it). Ghosts only materialize if their urn or headstone is placed physically on the lot somewhere. Good luck with your other issue.
Not a good idea to keep headstones or urns in Sims inventory for extended periods of time. Doing so has the potential to corrupt your game. It is best to move them to a permanent resting place and leave them there.