Try to release resources after the cmd finishes