I've gone off the rails a few times in my life. It's usually caused by intensely painful relationship troubles, which triggers my depression, ocd, negative thoughts, suicidal tendancies, heavy drinking and medication abuse, self harm. It's really dangerous for me to be depressed, when it's really bad I can hallucinate, get paranoid, think some really obscure things and feel so unreal. This has often ended up in me hitting rock bottom time and time again, ending up in the psychiatric ward with stitches in my arms.
There's not a lot I can do to prevent it, once the ball is rolling, besides never falling in love again... But it can still happen. Love isn't the cause of mental illness, but a broken heart can sure amplify it and make it much more unbearable. So I go through it all, get back into therapy, and try again.