A perforating gun has shaped charges that can generate a high-pressure gas. A valve sub connects to the perforating gun and a reservoir sub connects to the valve sub. The valve sub has an enclosure with a port. A mandrel in the enclosure has a piston head and a fluid path extending at least partially through the mandrel. A sleeve is slidably mounted on the mandrel and selectively blocks fluid flow through the port. A pressure chamber in the sleeve receives the generated high-pressure gas via the fluid path. The sleeve slides toward the perforating gun after a predetermined pressure is created by the generated high-pressure gas in the pressure chamber. The reservoir sub may have at least one chamber in fluid communication with the interior of the valve sub.