I recently did the visa cancellation of my ED visa before leaving Thailand (apparently this is the correct way). It took about 3 hours at main Chiangmai immigration and I needed a letter from the school as well as copies of passport page, all stamps, all 90 day reports and TM30.