Ensures namespaces are exited on error