Sw4nny has given you part of an explanation here for your problem , but I think alittle more info would help here ....
Read it all before you do anything ....
The motor is inside the plastic casing you can see with the shelf removed, and all the hydraulic and electrical cables and the bypass cable ( Bowden ) are held by the lower section of the two part plastic casing which houses the actual pump and motor assembly , this lower casing is also attached in most cases ( unless your lucky ) to the roof frame by either a screw or a cable tie or both .
Simply snipping the cable ties you can see with the parcel shelf removed isn't likely to release the motor casing .
The motor casing has two halfs , the cables and connections are attached to the bottom half, which is the half attached to the frame , so unless the casing isn't attached to the roof frame you still won't be able to remove it . Same applies to removing the top of the casing, the motor is still held in by the fact that the bottom casing is holding all the pump and motor cables , however removing the top will help you gain extra purchase on the motor and pump assembly to break the complete motor pump and Lower casting free from the roof frame .( you have to break the screw lug / cable tie or both to get it free)
Now ...... Your problem appears to be that the bypass cable isn't working correctly . First check that you have pulled the red handle out of its guide and turned it 90 degrees and located it correctly in its locked out position . If you look at the red handle ( the inner cable ) and its outer cable socket ( black guide where the red handle fits in ) you will see that they have slots , grooves and channels and guides that allow you to lock the handle in its out position .
The cable has a simple mechanical operation at the pump end ,where pulling it out and locking it into to out position pushes a ball value in ,that bypasses the pump hydraulics . If your roof simply goes half down with the handle pulled out correctly ,and then locks up , the hydraulic fluid isn't running through the pipes fully as it should . ...... Or there is an obstruction in the folding mechanisum ( unlikely but not impossible )
What is happening here if it's not an obstruction , is that it starts to go down and fluid flows into the resouvior ( but not out the other side ) until the resoviuor is completely full and then locks up as there isn't any more room for the remaining fluid in the resoviuor , it needs to come out to completely lower the roof , but it can't ,so it stays in the pipes leaving the roof partly up/down . It should flow through the pump and into the Rams . ......., see the pump operates by pushing hydraulic fluid around a closed system with two Rams , one each side of the roof mechanisum.
The pump has 4 pipes attached to it , put simply 2 are up pipes and 2 are down pipes . Press the up button and the pump runs one direction and pumps the fluid into the up pipes , this pushed the Rams up, and empties the down pipes ( all via the resoviuor) , press the down button and the pump runs the other direction and pumps the fluid into the down pipes that push the Rams the other way and empties the up pipes . Simple
The bypass cable just allows fluid to free flow manually without the pump doing anything .
The bypass cable ( Bowden cable ) has a white adjuster on it , between the red handle and the pump . Follow the cable from the handle around the roof edge under the boot with the shelf removed and you should find it , it's white and unscrews in two halfs, as you unscrew it the cable , any slack is taken up, it's possible you just need to adjust it tighter as its not fully engaging and depressing the ball value when in its out position, try tightening ( unscrewing the adjuster a couple of turns ) . If you adjust it too far the motor will not pump the fluid correctly after you've put the handle back in the non bypass position , re adjust until the pump works correctly , manually and with the pump .
A correctly working roof should operate from start to finish in about 12 seconds up or down .
Hope that all makes sense ?