I did some measurements to the circuit, and found out that the transistor grounds pin 5 when the magnet is close to the circuit, and pin 5 'floats' when the magnet is away (and the alarm sounds).
So the magnet closes the switch, which then grounds pin 5 via the transistor.
It would be more cost...