If your middleware method is actually async:
public async Task InvokeAsync(HttpContext context)
You can simply return:
if (User == null) { await _signInManager.SignOutAsync(); context.Response.Redirect("/"); return; }