XEP-0198: Cope with multiple 'closed' events

... and: s/waiting/pending/.

THIS COMMIT IS MEANT TO BE SQUASHED INTO A PREVIOUS ONE WHEN THE HISTORY
OF THIS FEATURE BRANCH IS REWRITTEN.