It's not designed to work that way. Under normal operation as designed to work, you set the burner and water flow using the knobs on the water heater to get the water temp to the shower head at the temp you want. If you turn down the flow of water using the water heater knob, the temperature will increase since the burner is still working at the same rate. At a certain temp the temp safety valve will kick in to shut off the burner to keep you from getting scalded.
The way you hooked it up causes the flow to the water heater to drop off. With the burner still operating at the same gas flow to the burner, water coming into the water heater starts to becomed super heated to a higher temperature and the temperature safety valve kicks in and stops the flow of gas to the burner. The water heater is still measuring the temperature of the water being output by the water heater to the hot side of the shower valve. It doesn't know that you have cold water coming in on the cold water side of the shower valve to cool the water back down. You're trying to use your shower heater like a regular water heater with a tank full of hot water.
The only safe "fix" is to replace your shower heater with a regular on demand heater made for a travel trailer. The dangerous fix is to override or remove the temperature cut off valve, but you very well may melt down and set the water heater and anything else around it on fire.
I have one of the water heaters like you have and mounted it to a piece of plywood that I could prop up against something or bungee to a tree. I use it when tent camping and used it at home to wash the dog outside. I may mount it inside a cargo trailer to camper conversion I am getting ready to build. The outlet will have a tee going to the kitchenette sink and to the shower hose with it's own shut off valve.