Implement cleanup correctly in OWIN middleware (fixes #1427).

OWIN does not call Dispose on middleware; instead, it signals a
host.OnAppDisposing cancellation token. Register the Web API OWIN
middleware for cleanup with that mechanism.