I do something similar. By whacking it (lol) my hand has enough momentum that the muscle twitch caused by the shock can’t overcome my hand’s movement, meaning it doesn’t jerk back uncomfortably.
It Lives - Roddy Piper discovers some special glasses that reveal one evil alien hiding among the populace. He has a 20-minute fight with Keith David over who gets to kill the alien. They kill it and then the movie ends.
This is relatable. In my experience, the only way to prevent is to make it literally impossible to leave for the place without bonking into the thing. Like don’t put the thing next to the door, put it in front of the door.