Close JavaScript Popup Window In Selenium WebDriver

When you open a webpage, you may find a lot of popup windows. How to close those popups in selenium automation test script? You can achieve that by using Windows Handlers API in selenium webdriver.