The regulation of hydrogen and oxygen escape from Mars