MercatorUi.Interfaces.IEngine engine;
if ((Session["CurrentEngineKey"] != null) && MercatorUi.Globals.EnginesUsedByExtApp.TryGetValue(Session["CurrentEngineKey"].ToString(), out engine))
{
    MercatorUi.Engine.Gescom.BillingEngine billingEngine = (MercatorUi.Engine.Gescom.BillingEngine)engine;
    billingEngine.Dispose();
    Session.Remove("CurrentEngineKey");
}