As with webpages, they can contain malicious code.
Yeah, that's true. Thanks.
Use Task Manager to close the pop-up (or your browser), and not the X or close button which may execute malware.
Ctrl-W closes tabs, Alt-f4 closes windows and Ctrl-Shift-Esc will bring up the Applications window of Task Manager. There are a few scareware pop-ups I've seen, often with audio, that hijack your browser (at least in Chrome) requiring a task manager closing of the browser.
Even better is to block them
Yes, and I often wonder whether there's a best browser for preventing pop-ups, best Adblock/pop-up extension or if they all do a similar job.