Yes, it is possible, but it does depend on firstly the illness or the cause of death. Many of the elderly people that I looked after, the majority either died from pneumonia or heart failure. In both these cases, there was no pain and they basically just slept. Other people I know who have died, did so due to a major heart attack or major stroke, in these cases death was immediate and there was no pain involved.
However, other people do experience pain but this depends on a number of factors - good pain management, good doctors/nurses and support team, family/friends support. But most of all the attitude of the person themself. Fear and stress does cause pain to be felt much worse, so if these can be reduced in anyway, then the pain would be considerably reduced. I know that some people who were terminally ill with cancer, in addition to their pain relief were also given relaxants and this helped a great deal. Others do meditations/relaxation techniques, and many join support groups. All these do seem to help in not only reducing pain, but lowering stress and fear levels. I don't know if this has answered your question, but yes it's definately possible to have a painless death.