Swartz committed suicide because he was mentally ill. He also attempted suicide multiple times in his life while not being "bullied".
If he was acting rationally and came to the conclusion that dying was better than spending X years in jail, he would have committed suicide after sentencing, not before any trial had even happened.