Only shutdown socket if both input and output are closed
Resolves issue #7