Temporarily block the door for everyone

Sometimes I don’t want to be disturbed, and I don’t want anyone to be able to go home (for example, when I’m in school).
So I would like no one or only a list of relatives to be able to use my lock … the others will have to ring.

Before when it was like that, I left the key in the lock which prevented it from entering. But now that is no longer possible.

It could also be reassuring against fear of hacking or accidental opening.