Stream could be null, so don't try to clean it up if it is already null