wstream: Fix close/free

The current code was leading to an invalid free when the wstream was closed