Yes they can in both cases. The spirit within man can grow during his lifetime to become stronger and more pure. When a person dies, this spirit is freed, and according to the way in which it has grown it will continue to exist in harmony and love (a state of grace / heaven) or it will fight the world, pulling things to itself and be consumed by anger, jealousy, and discontent (a state of pain / hell). The latter can, in my belief, actually kill a spirit completely, so hell isnt always permanent but because our religious teachers dont want any spirits to die we are told its forever, to help us stay away from that fate.
A persons spirit can, however, grow so bright that it can be seen already while it is alive, like with many religious figures and other very enlightened people. There are cases where a persons spirit overcame the reality of his or her body before they died, and ascended to heaven, or otherwise dematerialized. Some say that these beings can form a body again at will and go back to heaven again at will - they are called angels, Masters, Lightguides, you name it.
Mind you - dont confuse the remains of energy that people leave on earth with their spirits. A person will leave an 'echo' when they die, a shell of energy. Sometimes people think this is the deceased person and talk to it and keep it around, untill it does things wildly different than the person ever would have. Communication with real spirits is very rare and this kind of playing with ghosts is dangerous and disrespectfull to the actual person who has died.