I've done both. Took 2 tabs of LSD one day (after having a previous psychotic/manic episode triggered by LSD around 6 or 7 months before) and I could feel myself going psychotic (paranoid, delusional, etc) so I took 2mg of lorazepam and 7.5mg of olanzapine (they were prescribed to my bf, not me) and it ended the trip. was back to normal (sleepier than normal actually) within an hour
as for preventing drug-induced psychosis - I'd say some of it is luck, but my best piece of advice would be to sleep every night, ideally at least 8 hours, no matter how awake or wired you feel (I find that even if I'm super awake still, if I lie down and turn all the lights off, I will eventually sleep) not sleeping enough or pulling all nighters makes everything 100x worse