Well there are people who are sure ghosts exist, and could give you information. My understanding is that there is not one fixed set of rules. It’s more that when someone dies, part of them isn’t ready to leave and sticks around. Usually there is a frame of mind which may have a reason, rather than a rule per se.
For example, with the guidance of such a person, I have met and communicated with the spirit of a former child who had died and was scared of what was next, so he was hanging around for comfort. We were able to offer him some better company that helped him choose to move on.