innanzitutto cambia id alla tabella,

table.setAttribute("id","table")


perchè usare come identificatore 'table' (esattamente come il tag) può comportare problemi inaspettati e imprevedibili.

se modifichi ad esempio in

table.setAttribute("id","tabella")


puoi scrivere ad esempio

close.setAttribute("onclick", function() {
dcument.getElementById('tabella').style.display = 'none';
});