“...The B-29 prototype was already flying before Pearl Harbor so they knew the B-17 would only have 5 years of front line service if that...” [DesertRhino, post 29]
The Army Air Corps issued the formal specification for the B-29 in 1939. Two prototypes were ordered in August 1940, and first flight was in September 1942.
Both the B-17 and B-29 flew in military service into the late 1950s.
B-17s were phased out of the bombing business immediately after the victory in 1945. They did some Air Sea rescue and Transport. The war used ones all came home and were mostly scrapped or sold. The ones used postwar for a few more years that were sitting on the ramp new at the end of the war.
They only stopped building them after the Trinity test.. just a couple of weeks before Japan surrendered.
They were only used as a bomber until 1946 except a few oddballs here and there like in Israel etc.