Optimizing maintenance service contracts under imperfect maintenance and a finite time horizon