Pretty simply put (as I agree) when you have nothing at all you have nothing to lose.
In fact I think you can look at a majority of the world's problems today and trace them back to this sentiment. Those with nothing to lose will start doing things that reflect that mindset.
True, I think that concept can also go ways to explain why when we aren't talking terrorism, but even just behaviour online, so much of the anger/resentment and what we refer to as 'trolling' these days is males. Generalising a bit, but I bet if we were to know who a lot of the anonymous avatars saying terrible shit online to other people were, it would largely be males feeling "stuck in a rut". There can be truths that many young males, largely talking teenagers, can go through stages of issues with aggression and hormones. However, putting that aside when we start to see people in their 20's/30's and later behaving terribly on the internet (not just 14-year-old Halo smack talk), you can bet it is still males, and many of whom have poor life/job prospects. Poor sexual/partner prospects also kick up behavioural issues. This is true even with terrorists. Many will fit the category of not just males, but
single males. I honestly think with promises that involve a sexual nature in an afterlife are stimulating such minds too. As much as everyone in modern pop culture makes jokes about virgins in the afterlife, the truth behind the power of such a concept may well be far more sinister.
Honestly, a lot of the nitty gritty psychology and exploration of behaviour and the minds behind actions as extreme as terrorism down to actions unacceptable online, have many ties. Trying to find ways to combat all of it is something that has no simple answer at all. All answers it does have as well are multi-faceted. So many things we need to try and do, from education to security. We just have to look at the trends though, nearly always males, and then often it will be males with poor life prospects and as I said in this post often single or with little romantic/sexual contact with others. Crimes committed of a sexual nature throughout history are littered through all religious faiths, wars and acts of aggression or power from males. It's not a coincidence and it's a topic for a serious discussion where many will only be able to joke about sex/partners/relationships. In general most humans need companionship or relationships to feel they are well-rounded or living a purposeful life. Not everyone (some can live alone), and no, absolutely no one can go after something like this by force, but many minds can end up in dark places living solitary lives with no companionship. It's why I am generally critical of the concepts of celibacy enforced in some religious doctrine. Largely speaking, it isn't healthy.
Going a bit OT, but I think there is so much value in breaking down some of these discussions to micro-levels like this rather than just focussing on terrorist groups/cells. There has to be research and understanding around the individuals themselves who carry out the atrocities and why they get radicalised. Especially why it is nearly always males.