fix instance termination.

the following still remains to be addressed:
- time gap between terminations
- prevent two instances from terminating simultaneously