One can do this only by attaching to Allah or His messenger or Imams (as). The way out is to recite tasbeeh with full concentration at a secluded place and talking to Allah s.w.t in person and by trying to attain more concentration in namaz. Also in free time try to see the creation of Allah on internet or TV, through hubble telescope or animal planet etc. This will increase your attachment with Allah s.w.t and come out of worldly attachments InshAllah