Using loops to exit devtools on server exit message and disconnected message to simply break as suggested in the comment.