Spin off?
If the prop rotation is correct for the motor it will not spin off, it justs get tighter.
Are you using the motor in a pusher layout?
A motor motor intended for a tractor arrangement is used as a pusher the nut will tend to spin off unless you use a counter clockwise prop.
You could use an M5 stiff nut. They lock on so do not spin off