Make delete() safe to use

Things that don't work in Lua currently:

- Calling delete(nil) in Lua. (Exception.)
- Calling delete() twice. (Crashes.)
- Calling delete() on an object which will be handled by the __gc finalizer. (Crashes.)

Address these things by adding a nil check to lua delete() and having the C delete helper nil out the pointer-pointer after deleting it.