add close() function to M2 server