Refactor window management in webchat.backend.js.
Second part of refactored window management.