bin: cleanup resources properly when the build failed