I'm having the same problem. The first time I tried to change something it seemed to work fine, I changed the amount of gold multiple times in 10 gold increments, but when I tried to change the gold to 30 higher it destroyed the castle. Also when I tried to decrease the amount of gold it instantly destroyed the castle. This was all with a soldier out on the field.
I'm trying it again as I type this, and it seems that if you change the amount then purchase something it works, but if you change the amount and then wait to gain more gold it will detect the changed value somehow and destroy your castle. That's what it seems to be, at least, I'm not entirely sure about that. :?
Edit:
If changing it, and the game makes a money increase, it will see the change and defeat. However if spending first, it will accept the new value. So just pause it, change money, and double click on some unit icon, you get plenty of money.
The nasty thing about the game, some quests still are pesky even with infinite money :-/ or I'm just that a lousy player.
So if you go into the Tech Tree when you're changing values and buy something before going back to the main screen, It will not detect anything.