Tin hat was the slang name soldiers gave to the steel helmet they wore to protect them from shrapnel etc at the start of the 20th century. It was, I imagine the last bit of kit they put on when getting into uniform and heading into action. Hence, the idea that "putting the tin hat on" something was, in effect the last straw.
Lid is also a colloquial name for a hat and the phrase "putting the lid on " something meant much the same thing
The earliest recorded use of the hat phrase in this way, however, dates back to just after World War I.