Change this to:

```C#
app.Use(async (context, next) => 
{
     if(_disposed) 
     {
         context.Response.StatusCode = 503;
     }
     else 
     {
        await next();
     }
});
```