Dispose resources in web host exception cases (fixes #1345).