Notification cancel button now works. And stops the currently attached listener so appropriate sensor is stopped.
Added static class StopListener to hold a single booleanvalue. Apparently, when "Close notification" is pressed the pending intent instantiates a new service class which has lost state and access to the listener.
So instead I simply set a value in StopListener that is set by the service and accessed by both listener objects. (This is probably not the ideal way to do this.)