Whatever comes to you, the first thing you should do is not the
allow that thing to cause panic in you, or in fact, let any
sentient thoughts arise in you. To do that, chanting is a good
practice.
If I were to meet ghosts again, I will chant Namo Ksitigarbha
Bodhisattva (na mo di zhang wang pusa). There are also some
powerful mantras against evil spirits, but usually to chant them
you must have the right knowledge and right views to use these
mantras. Perhaps Origami can tell you a bit more?
However, if a ghost really wants to harm you with great hatred,
chanting may not be enough in long term... you must seek help from
a monk/guru/etc... even seek forgiveness from your "creditors" of
previous lives. I don't know what exactly will be done.
Ghosts, don't bother about them, "xin li mei you gui", usually they
won't find you 