If the liftgate and hatch are both "closed" but you're still getting the error message, you might have the same issue I did. I would have to push the striker area on the hatch into the vehicle while the hatch was almost closed in order not to get the dashboard warning. Its apparently a sensitive switch.
Mine was a problem when new so if this is something new for you then perhaps the latch bolts have slipped and need to be adjusted and tightened.
In my case, the dealer tried that and it only worked for a few days. I solved it by simply turning the rubber bushings clockwise at the bottom of the hatch by half a turn at a time, so they're not pushing the hatch outward as much (to prevent rattling). You might want to try that if yours has done this occasionally since new. If it's a new issue on an older vehicle, could be the latch needs adjustment or your hatch closed limit switch is bad.