dgram: close and release handle in time
- For 'lookup' function, when there's an error thrown out, 'state.handle' should be closed and released in time, because we don't need a useless handle when error is thrown out.
- For 'replaceHandle', release the old handle in time.