Chances are that the micro-switch that is registering the hatch as "open" was damaged - and it's inside the mechanism. As others have said, its time for a new mechanism, unless you are able to remove and disassemble the old one and repair or replace the micro-switch. I've done this on a few other cars but not on an X5 so I don't know how feasible this is.
You can see the micro-switch in this image from
freddan in his post from last year....
http://www.xoutpost.com/bmw-sav-foru...-lock-fix.html