Prevent static destructor crashes with ptx/opencl

1) Leak the static contexts because the destructors might get called late
2) Early-out from dev_free if there's no device pointer. Otherwise acquiring
the context barfs.
3) Add an actual error message when a Buffer destructor fails to clean up a
device allocation.
Merge branch 'master' of github.com:halide/Halide