properly clean up bundle environment