This paper studies the spare parts end-of-life inventory problem that happens after the discontinuation of part production. A final ordering quantity is set such that the service process is sustained until all service obligations expire. Also, the price erosion of substitutable or new generation products over time makes it economically justifiable to consider switching to an alternative service policy for repair such as swapping the old product with a new one. This requires the joint optimization of the final order quantity and the time to switch from repair to an alternative service policy. To the best of our knowledge, the problem has not been optimally solved yet either in its static or dynamic formulation. In the current paper, we solve its static version as a bi-level optimization problem. We investigate the convexity of the objective function and give a computationally efficient algorithm to find an exact optimal solution up to any given numerical error level ? > 0. We illustrate our approach on some numerical examples and compare our results with earlier works on this problem.