diff --git a/uhepp-js/src/components/UheppHistUI.jsx b/uhepp-js/src/components/UheppHistUI.jsx
index 4290374f4ae83b1a9df43561ea7d80468e7c1232..5cb81b17f371d6ecdab4fb063c7a738778c7e581 100644
--- a/uhepp-js/src/components/UheppHistUI.jsx
+++ b/uhepp-js/src/components/UheppHistUI.jsx
@@ -214,6 +214,8 @@ const UheppHistUIWithSyst = ({
   origYields,
   envName,
   envId,
+  setIsClean,
+  isClean
 }) => {
   const [include_underflow, setUnderflow] = useState(!!uhepp.bins.include_underflow)
   const [include_overflow, setOverflow] = useState(!!uhepp.bins.include_overflow)
@@ -247,25 +249,31 @@ const UheppHistUIWithSyst = ({
     setRebin(uhepp.bins.rebin || uhepp.bins.edges)
     setDensity(uhepp.bins.density_width)
     onReset()
+
+
   }
 
   const handleRebin = (e) => {
     let values = Array.from(e.target.selectedOptions, option => parseFloat(option.value))
     setRebin(values)
+    setIsClean(false)
   }
 
 
   const handleUnderflow = (e) => {
     let value = e.target.checked
     setUnderflow(value)
+    setIsClean(false)
   }
   const handleOverflow = (e) => {
     let value = e.target.checked
     setOverflow(value)
+    setIsClean(false)
   }
   const handleDensityWidth = (e) => {
     let value = parseFloat(e.target.value)
     setDensity(value)
+    setIsClean(false)
   }
 
   const uhepp_derived = Object.assign({}, uhepp,
@@ -676,20 +684,32 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
   const [envName, setEnvName] = useState("NOMINAL")
   const [stacks, setStacks] = useState(uhepp.stacks)
   const [ratio, setRatio] = useState(uhepp.ratio || [])
+  const [isClean, setIsClean] = useState(true)
+
+  const getClean = () => isClean
+
+  window.onbeforeunload = () => {
+    if (!isClean) {
+      return "Really exit?"
+    }
+  }
 
   const reset = () => {
     setEnvId(0)
     setEnvName("NOMINAL")
     setStacks(uhepp.stacks)
     setRatio(uhepp.ratio || [])
+    setIsClean(true)
   }
   const handleEnvelop = (e) => {
     let variationName = e.target.value
     setEnvName(variationName)
+    setIsClean(false)
   }
   const handleEnvStack = (e) => {
     let stackId = parseInt(e.target.value)
     setEnvId(stackId)
+    setIsClean(false)
   }
 
   const handleStackContentChange = (e, stackId, itemId) => {
@@ -697,6 +717,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
     setStacks(patchList(stacks, stackId, Object.assign({}, stacks[stackId],
       {"content": patchList(stacks[stackId].content, itemId, Object.assign({},
       stacks[stackId].content[itemId], {"yield": yields}))})))
+    setIsClean(false)
   }
 
   const handleStackItemRename = (e, stackId, itemId) => {
@@ -704,6 +725,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
     setStacks(patchList(stacks, stackId, Object.assign({}, stacks[stackId],
       {"content": patchList(stacks[stackId].content, itemId, Object.assign({},
       stacks[stackId].content[itemId], {"label": label}))})))
+    setIsClean(false)
   }
 
   const handleStackItemChangeColor = (e, stackId, itemId) => {
@@ -713,6 +735,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       stacks[stackId].content[itemId], {"style": 
       Object.assign({}, stacks[stackId].content[itemId].style || {}, {"color":
       color})}))})))
+    setIsClean(false)
   }
 
   const handleAddStackItem = (e, stackId) => {
@@ -720,6 +743,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
     setStacks(patchList(stacks, stackId, Object.assign({}, stacks[stackId],
       {"content": [...stacks[stackId].content, {yield: [], label: "New item",
       style: {}}]})))
+    setIsClean(false)
   }
 
   const handleMoveUpStackItem = (e, stackId, item) => {
@@ -731,6 +755,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       stacks[stackId].content[item - 1],
       ...stacks[stackId].content.filter((_, i) => i > item),
       ]})))
+    setIsClean(false)
   }
 
   const handleMoveDownStackItem = (e, stackId, item) => {
@@ -742,27 +767,32 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       stacks[stackId].content[item ],
       ...stacks[stackId].content.filter((_, i) => i > item + 1),
       ]})))
+    setIsClean(false)
   }
 
   const handleDeleteStackItem = (e, stackId, itemId) => {
     e.preventDefault()
     setStacks(patchList(stacks, stackId, Object.assign({}, stacks[stackId],
       {"content": stacks[stackId].content.filter((_, j) => j != itemId)})))
+    setIsClean(false)
   }
   
   const handleDeleteStack = (e, stackId) => {
     e.preventDefault()
     setStacks(stacks.filter((_, i) => i != stackId))
+    setIsClean(false)
   }
   
   const handleAddStack = (e) => {
     e.preventDefault()
     setStacks([...stacks, {"type": "stepfilled", "error": "stat", content: []}])
+    setIsClean(false)
   }
 
   const handleStackTypeChange = (e, stackId) => {
     const type = e.target.value
     setStacks(patchList(stacks, stackId, Object.assign({}, stacks[stackId], {"type": type})))
+    setIsClean(false)
   }
 
   const handleMoveDownStack = (e, item) => {
@@ -773,6 +803,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       stacks[item ],
       ...stacks.filter((_, i) => i > item + 1),
     ])
+    setIsClean(false)
   }
   
   const handleMoveUpStack = (e, item) => {
@@ -783,12 +814,14 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       stacks[item - 1],
       ...stacks.filter((_, i) => i > item),
     ])
+    setIsClean(false)
   }
   
   
   const handleDeleteRatioItem = (e, itemId) => {
     e.preventDefault()
     setRatio(ratio.filter((_, i) => i != itemId))
+    setIsClean(false)
   }
   
   const handleAddRatioItem = (e) => {
@@ -800,11 +833,13 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       denominator: [],
       style: {}
     }])
+    setIsClean(false)
   }
 
   const handleRatioItemTypeChange = (e, itemId) => {
     const type = e.target.value
     setRatio(patchList(ratio, itemId, Object.assign({}, ratio[itemId], {"type": type})))
+    setIsClean(false)
   }
 
   const handleMoveDownRatioItem = (e, item) => {
@@ -815,6 +850,7 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       ratio[item ],
       ...ratio.filter((_, i) => i > item + 1),
     ])
+    setIsClean(false)
   }
   
   const handleMoveUpRatioItem = (e, item) => {
@@ -825,22 +861,26 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
       ratio[item - 1],
       ...ratio.filter((_, i) => i > item),
     ])
+    setIsClean(false)
   }
 
   const handleRatioItemChangeColor = (e, item) => {
     const color = e.target.value
     setRatio(patchList(ratio, item, Object.assign({}, ratio[item],
       {"style": Object.assign({}, ratio[item].style, {color: color})})))
+    setIsClean(false)
   }
 
   const handleRatioItemNumeratorChange = (e, itemId) => {
     const yields = Array.from(e.target.selectedOptions, option => option.value)
     setRatio(patchList(ratio, itemId, Object.assign({}, ratio[itemId], {"numerator": yields})))
+    setIsClean(false)
   }
   
   const handleRatioItemDenominatorChange = (e, itemId) => {
     const yields = Array.from(e.target.selectedOptions, option => option.value)
     setRatio(patchList(ratio, itemId, Object.assign({}, ratio[itemId], {"denominator": yields})))
+    setIsClean(false)
   }
   
   const mod_uhepp = Object.assign({}, uhepp, {"stacks": stacks, "ratio": ratio})
@@ -906,6 +946,9 @@ const UheppHistUI = ({width, height, uhepp, uuid, size}) => {
             onRatioItemDenominatorChange={(e, i) => handleRatioItemDenominatorChange(e, i)}
             onRatioItemChangeColor={(e, i) => handleRatioItemChangeColor(e, i)}
 
+            setIsClean={isClean => setIsClean(isClean)}
+            isClean={isClean}
+
             envName={envName}
             envId={envId}
             uuid={uuid}