A non-transitory computer-readable storage medium storing a program for causing a computer to execute a control method for an image forming apparatus, the image forming apparatus comprising:
- a printing unit that performs drawing on a recording medium;
- an image sensor that detects completion of the drawing on the recording medium by the printing unit;
- an output unit that outputs the recording medium on which the drawing has been performed;
- an output sensor that detects presence or absence of the recording medium in the output unit;
- and
- a nonvolatile memory that stores first information for use in calculating a usage fee for the image forming apparatus and second information indicating whether or not the drawing on the recording medium by the printing unit is completed,
- the control method comprising:
- upon the image sensor detecting completion of the drawing on the recording medium by the printing unit during execution of a chargeable job, carrying out a first updating process including updating the second information to a first state indicating completion of the drawing;
- after the second information is updated to the first state, carrying out a first output starting process including instructing the output unit to output the recording medium and starting monitoring of the output sensor;
- carrying out a second updating process in a case where it is determined that the recording medium has been output from the output unit as the output sensor being monitored no longer detects the recording medium after the output unit is instructed to output the recording medium in the first output starting process, the second updating process including updating the second information to a second state which is different from the first state and updating the first information;
- terminating the chargeable job without updating the first information in a case where an error occurs in the image forming apparatus while the recording medium is detected by the output sensor being monitored after the output unit is instructed to output the recording medium in the first output starting process;
- carrying out a second output starting process in a case where the output sensor detects presence of a recording medium inside the output unit when the image forming apparatus is powered on, the second output starting process including instructing the output unit to output the detected recording medium, and starting monitoring of the output sensor;
- reading a state of the second information from the nonvolatile memory in a case where the output sensor being monitored no longer detects the recording medium inside the output unit after the output unit is instructed to output the recording medium in the second output starting process;
- carrying out a third updating process including
- updating the second information to the second state without updating the first information in a case where the state of the second information that has been read is the second state, and
- updating the first information and then updating the second information to the second state in another case where the state of second information that has been read is the first state;
- in a case where the second information is updated to the second state in the third updating process, increasing by one a number of times that the image forming apparatus was powered off during output of recording media by the output unit, which is stored in the nonvolatile memory;
- and
- in a case where the number of times that the image forming apparatus was powered off is smaller than a predetermined value in the second updating process, shifting a time to update the first information to an end of the chargeable job.