call document.close() after finish writing to the iframe's document