Are you force carbonating or naturally carbonating? If the latter then just purge the headspace and give it enough gas to seal the keg. If the former you definitely need to leave the gas connected (at least until it's carbonated, at that point you can remove the gas).