Properly shutdown streams and devices