Prevent immediate shutdown of Streaming context after JVM shutdown

I have a spark application running and am facing some issue. Whenever the JVM shuts down, the Streaming context immediately shuts down. I want the context to shut down properly. So how to disable the immediate shut down function?