It wasn't nearly cancelled. Robert Jordan picked sanderson and passed on his notes, ending. He even wrote the last parts of the book. It's planned as well as it could be.
A few misleading statements here: it was RJs wife who picked Sanderson, after RJs death. Additionally, RJ had the last scenes written well before he even knew he had cancer. I believe he mentioned having it written while writing the very first book.