Software rejuvenation is the proactive maintenance operation for software systems that experience software aging causing degradations in system performance and reliability. The normal system performance can be recovered by software rejuvenation, which restarts the software system to clear all the internal error states due to software aging. Since software rejuvenation drops all the jobs in the system, a trigger for software rejuvenation needs to be carefully determined in consideration of such costs. In this paper, we theoretically derive the optimal policy that minimizes the cost of decision for software rejuvenation in a deteriorating job processing system, which is modeled as an M/M/1 queue with infinite buffer size. In our model, the number of queued jobs is used to represent the system state and the decision of rejuvenation is made upon the completion of a foreground job. We formulate the problem as an optimal stopping problem to analytically derive the optimal policy for the rejuvenation decision. The analytical results show that the optimal stopping policy is determined by the service degradation rate, the costs of dropped jobs and delayed jobs, and it does not depend on the number of queued jobs. This indicates that whether to trigger rejuvenation can be decided immediately when the system confirms the level of service degradation, regardless of the number of queued jobs at that time instant.