The move of an employee from one country to another does not necessarily imply the end of their tax and social security obligations.
On the contrary, it is very common that when long-term incentives are paid (stock options, bonuses, etc.), new obligations arise in the countries where the employee is no longer. At the same time, it is possible that the company in Spain is obliged to make withholdings for the entire incentive payment.
Therefore, each case must be analyzed individually, taking into account the periods in which each employee could have been in each country, bearing in mind the Spanish regulations and the provisions of the International Agreements.