Fix bug where the program would sometimes hang on node release