The first thing to look for when the dishwasher door is not shutting properly is jammed dish racks. The racks glide on little tracks with plastic or rubber wheels, and the tracks can become jammed or the wheels can break over time, making it difficult to push the racks back into the dishwasher. Check to make sure the racks are pushed back into the dishwasher's chamber and try closing the door again.
Dishwashers have door latches that typically slide to lock. It's possible that this locking mechanism is jammed, either with food particles or by a broken internal component. The door latch will most likely need to be replaced in such cases. Remove the covering of the door latch with a screwdriver and check for obstructions before considering a complete replacement.
The dishwasher door operates on hinges that allow it to open to a 90-degree angle. The hinges could potentially become warped or jammed, which would lead to difficulties opening and closing it. Check the hinges for any obstructions, or replace them if they're bent or broken.
Door gaskets are rubber seals that run along the interior perimeter of your dishwasher door. These gaskets are designed to create a watertight seal so water doesn't spill out onto your kitchen floor. New gaskets are more solid than gaskets that have seen some use, and therefore they may have difficulty creating a seal. Push hard on the door to seal it, and give the gaskets a few cycles to soften if the door latches and hinges seem to be in perfect working order.