The risk reserve process of an insurance company within a deteriorating Markov-modulated environment is considered. The company invests its capital with interest rate α; the premiums and claims are increasing with rates β and γ. The problem of stopping the process at a random time which maximizes the expected net gain in order to calculate new premiums is investigated. A semimartingale representation of the risk reserve process yields, under certain conditions, an explicit solution of the problem.