Just close the socket fd. It will automatically deregister itself from epoll. I asked a similar question last year and got this answer:
Is it necessary to deregister a socket from epoll before closing it?
If you need to do additional cleanup on the write thread for this socket, just have your write thread also listen to the read-end of a pipe fd. Notify this thread by writing a single-byte to the pipe (but not before queuing up a message to a thread-safe message queue indicating the details of what to cleanup).
When epoll_wait returns indicating data on the pipe, read the bytes off the pipe, consume the messages on the queue, and do appropriate clean-up work.
Hope this helps.