Mitmproxy dump wrap and signals

I’ve wrapped mitmproxy and launched it with subprocess but i’d like to close and stop it’s recording with “Enter” press instead of “Ctrl+c” (since pressing “enter” is much more intuitive for users").

But I’m getting that mitm dump either stays after closing the subprocess or it closes without calling the “Done()” hook that the har addon uses.
Is there any good workaround for such issues? I’ve been thinking on simply using mitmproxy as library and launching it without wrapping but I’ve seen that mhils has discouraged against it… any other solution?