Ah, well, for any pokemon that's misbehaving, sometimes a useful deterrent is to give them a clear warning, then recall them to their balls if they continue. Of course, that only works if they like being out in the first place... Similarly, try finding what, if any, sorts of treats they prefer, and have a supply ready to give them whenever you catch them behaving well.
...though, ghost types do tend to be more problematic than most....
Video
...though, ghost types do tend to be more problematic than most....