For automatic cleanup, you can try bash's trap command. Set up a cleanup trap when you create the file.
In .ssh/rc:
if [ -n "$DOMAIN" ]; then
# ... create socket & report to user
clean_socket(){ rm /tmp/test.dev.tld.socket; }
trap clean_socket EXIT INT HUP;
fi