Android "onApplicationPause" (Minimizing an application)

I would like to know how to utilize onApplicationPause is so I can destroy my websocket connection when the application is not in use, there’s no reason to constantly drain the users battery with a keep-alive connection of a “paused” application. It will also reduce the amount of concurrency/scalability required on the server, although not that handling PING/PONG requests is really that taxing.