When is the "slam" used?
Answer from a Native speaker
The word slam here is being used as an onomatopoeia. Onomatopoeias are words in English that are imitations of the sounds they represent. Sometimes these words can also function as verbs. Since the slam is being used as an onomatopoeia here it means to make a loud bang caused by the forceful hitting or shutting of something. When a word is being used as an onomatopoeia it is essentially an exclamation. Ex: Slam! They crashed into each other. Ex: His hand hit the desk hard. Slam! Ex: She stormed angrily out of the room. The door closed with a loud slam!