How to detect if Sample Recorder is recording?

Hi, is there some way of detecting if the Sample Recorder is recording or not?

I use Esc for edit mode on/off, but Esc also cancels (!) and hides the sample recorder.

How would I go about detecting that if the Sample Recorder is recording, then either stop recording, or at least don’t hide the sample recorder dialog.