Clean up resources after done (-x)

Signed-off-by: nixnodes <code@eth.si>