human
Give me a Python program to close socket gracefully.
assistant
Here is a Python program to close socket gracefully

import socket

def close_socket_gracefully(sock):
    """Close socket gracefully."""
    try:
        sock.close()
    except Exception as e:
        print(("Error: %s" % e))

# Enter the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Calling the function
print((close_socket_gracefully(sock)))

#Example Output
# None

#Remember to inspect code for bugs.