Cleaned up stream/socket closing.