i can hear my engine knocking only sometimes when i turn my car off. any help? on 2003 Audi A4 Quattro

it a 2003 Audi A4 1.8t inline 4. for some reason only occasionally will i hear the engine knock only when i shut off it never does it while i drive or turn it on. just when i turn the ignition off. if anybody knows please help. thanks.

Asked by for the 2003 Audi A4 Quattro