[MAT-387] Reset shared_ptrs in jterminals test

This is so that they can be deleted whilst the JVM and environment
is still around for their unbinding.