Erasing a flash sector (sets all the bytes to 0xff) is likely to take 100ms or so, and writing every location (which can only clear bits) getting on for the same time.
IIRC no other accesses to the flash can be done while a write (of an individual word) or an erase is taking place.
I don't know how the altera functions work, the write is almost certainly synchronous, the erase might not be.
I'd try running your software with the actual flash writes commented out (or test using SDRAM instead) and replaced with spin-loop delays, you might find you have a simple logic problem.