fixing listener failure bug, listener not always closed when restarting leading to listener failure