Of course masturbation does not fall under actual Zina. According to the majority of scholars this bad habit is prohibited as they quoted verse 5 of Surah al-Mu’minoon as evidence for the prohibition.
Masturbation does not entail any legal penalty. However, one has to repent sincerely to Allah and fill his time to acts of worship keeping himself or herself away from causes of temptations and sexual excitement. The following could be useful advices:
1- Observe fasting, because it bolsters one’s faith, preserves chastity, and protects one from evil thoughts.
2- Observe moderation in eating and drinking in order to avoid stimulating your desire
3- Keep away from anything that is sexually stimulating, such as pornographic pictures, erotic films and love songs.
4- Choose good and righteous friends
5- Keep yourself busy in worship and spiritual acts
6- Interact with activities of the society in such a way that it keeps you away from thinking about sex
7- Avoid gatherings and places that bring men and women physically close to each other.
In general, masturbation does not violate virginity. However, if practiced by a woman, it may result in losing her hymen, which could be of serious psychological and social consequences.