Modify stream stop API to prevent segfault