proper cleanup of resources in recompute command

Recompute command wasn't closing the streams properly, so this patch has them all close when errors happen.