Is masturbation allowed for a married person when he is away from his wife?
As I understand, masturbation is generally considered forbidden in Islam since it is deemed to fall under the category of sexual gratification outside the framework of marriage. However, when it is the only choice in order to avoid committing the major sin of zina (fornication or adultery), one can resort to it without exaggeration bearing in mind that he/she should do his/her best to satisfy his/herself within marriage.
Thus, masturbation is only looked upon as an option if it is the ONLY way to avoid committing the sins of fornication or adultery. It is better if one doesn't masturbate at all, but if you find yourself in a situation where you truly believe that you will commit zina if you do not masturbate then in this case it is generally seen as the lesser of two evils, but still something you should ask forgiveness for from Allah Subhana wa ta’ala.
It is really a "worse case scenario" option.
My ultimate advice to you is that if you feel convicted about something (like not masturbating), then you should avoid engaging in the behaviour and do not do it. Salaam