Thermal stability of superconducting YBa2Cu3O9−x in different environments