env: cleanup handles properly