When my mare was 2, she would get aggressive with me in her stall, but be as sweet as honey everywhere else. So I understand completely. It was like she was saying, "Hey! This is my territory! And mine only!" While she was in her "castle", she "ruled."
Thankfully when I moved her to a different barn, she got a stall with an outdoor run. She'd get very aggressive at feeding time (like, "Give it to me and get out!"), so we took a whip and chased her out. I've gotten her to the point where she cannot take a step inside the stall without my say. The stall is "my territory", and I'm graciously letting her use it. She's very good about it now, and isn't aggressive in the least anymore. When I took her to a driving trainer, she had just a stall, no run. The trainer's wife would do feeding every morning, and commented to me how unusual it was that my mare would "turn around, go to the far corner, put her head down, and wait until the feed had been put in the stall, and everyone was out before she started eating." I figure this was my mare's way of getting out of the way, as she was never aggressive, and never turned around until the feeding person had left the stall.
My Mom's gelding also had a habit of turning his butt to me in his stall. I hated doing it, but all I could do was hit him on the butt with the whip until he turned around. He never kicked, but it did work, and he always keeps his eyes on me now.
Hope you figure this one out soon! Be careful!