Closing the door has become a conditioned stimulus.
The term conditioned stimulus comes from Pavlov and his experiment on dogs. Each time he wanted to feed the dog, he would ring a bell to let the dog know food was coming. After a while, the dog would start salivating each time it heard the bell because it knew it was going to be fed soon. The case above is similar - whenever Dr. Garcia closes the door, the students assume he will give them a pop quiz.