protected override void OnStop()
{
var owinhost =
Application.PeerCast.OutputStreamFactories.FirstOrDefault(factory => factory is OWINHostOutputStreamFactory) as OWINHostOutputStreamFactory;
if (owinhost!=null) {
foreach (var app in applications) {
owinhost.RemoveApplication(app);
}
}
base.OnStop();
}