There is no clear explicit rule.
Neither the Constitution nor the Reglament of Congress says anything about limiting the resignation of the Prime Minister, either in the case of a motion of no-confidence or otherwise. Since Art. 113 of the Constitution makes a point of explicitly forbidding the calling of new elections but say nothing about the possibility of dimission, I would understand it as not forbidding it.
Furthermore, in all of the mentions to the possibility of the PM resigning it is treated exactly as if it would be treated the possibility of the PM's death. Since death cannot be forbidden by lawcitation needed, it is reasonable to expect that a dimission would be treated the same way. The PM and his government would continue in functions.
That said, after the government has resigned, there is little sense in following with the motion of no-confidence:
As the name implies, it is against a government that no longer is. A part of the parliamentary procedure is attacking the current government policies (by the candidate) and the government defending itself. Does not make much sense.
The motion of no-confidence might lose support after the resignation. The ruling party might propose a candidate that is more acceptable than the candidate of the motion of no-confidence to some of the supporters. Supporting a candidate of other party may be more unpopular among the electorate if it is not against an unpopular PM1. Some parties may prefer the motion of no-confidence to fail so that no new candidate is elected and new elections are called for.
The motion of no-confidence is more difficult to pass than a normal election. A motion of no-confidence needs a majority (more than half of "yes" votes). The election of a new PM by the standard procedure after the resignation of the PM needs only a plurality (more "yes" than "no" votes) in the second round to succeed.
If the motion of no-confidence is recalled, it can be called again by the same people in the same legislature. If it is voted and fails, the people that pushed for it are not allowed to call for a new one until the next elections.
So, even if the motion was allowed to continue2, it is in the best interest to voluntarily retire it.
All of which kind of introduces a possible loophole to the prohibition of calling new elections: the PM resigns, the motion of no-confidence is dismissed, the different parties cannot agree in a new candidate3 and new elections happen. But new elections is the last thing that the current PM and his party want, they want to delay elections as much as possible to hope that the damage of the corruption fades away from memory, so I doubt very much that there will be any dimission.
1 Supporting other party's candidate almost always is unpopular (why vote for X if he ends supporting Y) with part of your electorate.
2 Which I would doubt based in the first of the above points.
3 Coincidentally, this is kind of M. Rajoy's greatest political ability.