With all due respect, I am going offer my two cents.
In your sentence, "X told me to close the door when I go out /when I went out."
To me, the correct sentence is (because it sounds as that in my ear) "X told me to close the door when I go out." and not "X told me to close the door when I went out."
Why? As i said before, it doesn't sound right. It might sound right if it is changed to:
X told me to close the door when X was going out.