Yes you can, your right to leave a job where the employer doesn´t meet his obligations is stated in article 50 0f the Statutes for Employees, but you must start a procedure through the social courts, asking for any late wages to be paid, AND your contract to be ended, for the reason of repeated non payment of wages (either 4 months without payment of wages, or wages repeatedly paid more than 11 days late). Only if the judge rules in your favour, the work contract will be ended and you will not lose your right to paro/unemployment benefits, provided you are entitled to any, naturally.
We strongly suggest you engage a professional specialised in labour law, to assist you with this. For instance from a workers union. CCOO and UGT are big unions in Spain. You can find a listing of offices on their respective websites.
More info
and in this document from our Library.