There’s something satisfying about slamming doors. For instance, slamming the door on your way out of the office after telling your boss, “You can’t fire me! I quit!” On an unrelated note, you shouldn’t do this. Your work contract might have a clause where quitting means forfeiting your severance pay.
Anyway, that’s probably the only time you’re allowed to slam a door. If you live in an apartment building and slam the door every time you leave or enter your unit, you’re a jerk. The loud sound can wake children and pets up, and nobody wants to hear babies cry or dogs bark long into the night.