mod_base: Make sure no messages are left in the request process's mailbox. Fixes #676

(cherry picked from commit 59162d5a082132a4aca3b2021b7753a50769f56c)

Conflicts:
	modules/mod_base/controllers/controller_comet.erl
mod_base: reapply change from d5604eca1f83491c37adf7981ff1cc598b7c57e2

(cherry picked from commit 70a517b2dcfdc669bb67b27cf281258d7ca0b753)
mod_base: Limit the number of websocket reconnects. Fixes #675

(cherry picked from commit 766a1adf614531b2f1bc5f604fc296ffef669e21)

Conflicts:
	modules/mod_base/lib/js/apps/zotonic-1.0.js
core: Prevent to detach comet controllers from page sessions which are already stopped.