how to auto close alert box javascript

JavaScript
window.setTimeout('alert("Message goes here");window.close();', 5000);
Source

Also in JavaScript: