Core: add debug logging to InternalEngine.close