Fixed the bug that when closing the php out stream will get segment fault.