Move ice bridge to pipe shutdown mechanism

I should change all the periphs over eventually..
Restore python context correctly on shutdown

I'd been ignoring a segfault on the destruction of the python
interpreter for a while. This commit saves and restores the
thread context correctly and fixes this bug.