Shutdown controller if not testing.

This required to add testcase for function redefinition or any DS related test through recorded test.