I used the same app note as the basis for my boot loader on an MC9S12DG128. It wouldn't erase the last sector where the ISR vectors and security bits were. Where are you trying to write? Is the page number correct?
How about the clock frequency of the flash block? I think that there is an error in the code for frequencies below 12MHz with an extra divide by 8 in the equation. Make sure that the FCLK frequency calculates out to be between 150 and 200 kHz.
As far as writing the last sector, I used redirection, pointing the ISR vectors to RAM. My application code fills this space with jumps to the real interrupt code. That way the last sector didn't need to be reflashed.
Since you were using the debugger, you might try ensuring that the memory window isn't looking at the address space that you are trying to flash. I had problems with that. Also page 3F was for 8000 thru FFFF. For some reason with page = 3F I saw the flash erased in the 8000 - BFFF area, but not in C000 through FFFF.
TaB