Rather than asserting, raise an error for the user and abort the
operation. This is motivated by the desire to get the test suite mostly
working on Windows so that the underlying issues can be worked through
more easily.
- Fix for https://bugs.swift.org/browse/SR-13561 by making sure the
session close waits for the open to finish
- Add a regression test
Change-Id: Iff7217d7b03bc797e036c5329afb0765dcc1874b