Or if you're at the very end and can't get a spanner or anything onto the flat bit at the end of the thread then:
- as mentioned before, wind the nut back on and make sure the thread is clean
- grip the shaft with your hand (do NOT use any tools to hold the shaft)
- use an impact driver with a deep impact socket to remove the stubborn nut
It's not exactly healthy for you to expose your body to that sort of shock for too long though, so use this method at your own risk. I've never had any issues though. So far...
The impact drivers torque is obviously applied in pulses, so your hand strength is enough to hold the shaft still and there will be plenty of torque to remove the nut.