I heard of both 'as' and 'when' in this situation.
It seems to me that the difference between them is,
'As' emphasizes the movement of leaving to go out
while
'when' emphasizes some point during the action of going out.
And basically, I can use "as" here in that it doesn't have the implication of the meaning of "because".