You need to call document.close(). document.write calls document.open if the document hasn't been opened. As long as the document isn't closed again with document.close the browser will indicate that the page is subject to change.
function fn() {
// implicit call to `document.open();` before document.write
document.write("Hello there!!!");
document.close();
}