Turning off/on node state in a flow with ui button help

Here is an example using context storage and a switch node.

[{"id":"5721dd2.ffcb4a4","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":2620,"wires":[["975c7e8b.83bc38"]]},{"id":"975c7e8b.83bc38","type":"ui_button","z":"b779de97.b1b46","name":"","group":"8b5cde76.edd58","order":9,"width":0,"height":0,"passthru":true,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"stopflow","payloadType":"flow","topic":"topic","topicType":"msg","x":350,"y":2640,"wires":[["79fabc8b.2e059c"]]},{"id":"79fabc8b.2e059c","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"stopflow","pt":"flow","to":"$$.payload ? false : true","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":2680,"wires":[[]]},{"id":"2d36fcf6.51fd9c","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":2760,"wires":[["450b3efe.bfc7d8"]]},{"id":"450b3efe.bfc7d8","type":"switch","z":"b779de97.b1b46","name":"","property":"stopflow","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":2760,"wires":[["945fecf5.86da68"]]},{"id":"945fecf5.86da68","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":2740,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Click button to enable click again to disable, press inject to see if payload passes.

or you can use a contrib node like node-red-contrib-simple-gate