The firm faces technological uncertainty associated with the success of the R&D effort and market uncertainty about the stochastic revenue flow generated by the new product. Our model departs from most R&D models by assuming that the firm's knowledge accumulation has an impact on the R&D process, so the hazard rate of arrival of R&D success is no longer memoryless. Also, we assume a finite life span of the technologies that the product depends on. In this paper, we propose efficient finite difference schemes that solve the Hamilton-Jacobi-Bellman formulation of the resulting finite time R&D stochastic control models with an optimal control on R&D expenditure and an optimal stopping rule on the abandonment of R&D effort. The optimal strategies of R&D expenditure with varying sets of model parameters are analyzed. In particular, we observe that R&D expenditure decreases with a firm's knowledge stock and may even drop to zero when the accumulation level is sufficiently high.