Updated close() to remove used DOM elements