You need to continue to hold the W key to keep moving forward.
When you click E, the hog will level itself out. You need to press E again quickly or you'll just fall out.
So the E key just lifts the tail of the hog back up, the W key is still the one that moves you forward so don't let go of W !
To expand on what Kiwi just explained (which is correct by the way):
What happens in that situation is that your front wheels (as you explained in the post) hang on to the ledge outside of the opening. This will only happen if your wheels are still moving, because otherwise the weight of the hog will drag it off the ledge and you would have to start over or go the long way.
The reason the E trick works is not because of a flaw in the programming of the game, but because of the things they did RIGHT. Normally when a hog is not in a very favorable position to drive in (on it's side, on it's back, etc.), you would use "E" or whatever key/command you use to flip your vehicle over. This much is obvious.
When you hit E to get out of your hog when it's over the edge, the game automatically reads it as in an unfavorable position. This causes the first button press outside of the hog to flip it in an attempt to level it out. Once it levels out the game allows you to get back in. From there it's just a mash-fest making sure you don't fall too far away from the hog to not be able to jump in again.
Now in order for the E trick to work you need to do 3 things:
1) Keep the hog straight!: Turning your camera, thereby turning the hog, will cause one of the wheels to slip off the ledge and cause the hog to fall.
2) Pedal to the Metal!: Mash your "W" or driving key to keep the momentum going, otherwise it will be on the way down when you first hit E outside of it, therefore flipping it off the ledge and crashing on the ground below.
3) Mash the E key!: If you delay in hitting it, all your hog will do is one of the two crash landings mentioned above.
*I think I could of explained it in less words but that's the jist of it
*