It should be possible to receive (keep-alive) comments in the application. This allows to track if the connection is still active and maybe add some shutdown logic.