When your cat scratches or "knocks" at your closed door, it can be very annoying, especially if you want to retire for the night. However, your cat is not scratching or tapping at your door out of spite. It may want food or attention. Also, a closed door is a natural challenge to a cat; you are cutting off access to yourself and a part of its "territory." If you respond by opening the door, you are simply reinforcing its actions. Attempting to punish the cat will only teach it to fear you and will not affect its behaviour. Instead, try a few techniques to discourage the knocking and treat yourself to some privacy or a restful night.
Place a vacuum cleaner next to your door inside your room. Plug the vacuum into a wall socket.
Close your door, leaving your cat outside. Wait for your cat to begin knocking at your door.
Turn the vacuum cleaner on. The sound of the vacuum cleaner will startle the cat and make it stop what it is doing. Repeat the process, every time you hear the cat tapping at the door, until it stops.
Place a box fan outside of your bedroom door or across the hall from your door.
Plug the fan into the closest wall socket and turn it on the highest setting.
Point the fan at your door so that the air is blowing towards it. A cat typically dislikes air blowing in its face, which will discourage it from tapping on the door.
Make a hissing sound at your cat if it starts to knock at your door. Make sure your cat has been fed and has a good supply of fresh water. Play with your cat right before bedtime. This will tire the cat out, discouraging it from becoming restless at nighttime.