When closing the compartment, be sure:
* that you are using force to close the door, a spring in the door will not allow it to swing shut on its own.
* that no part of the battery is protruding from the door.
* that when you are closing the compartment, the door is shut and then slid forward to be officially locked into place.
If this problem persists, you can find a replacement door on ebay for around $6-$10.
Hope this helps!