pushed the closing/joining logic into run_forever()