Check for valid socket resource before closing the AMQP connection

During the course of development, I ran into a situation where my code was trying to close the AMQPConnection multiple times. Besides this being poorly coded on my end, I thought it would be useful to check for a valid socket before trying to close the AMQP connection to RabbitMQ.