merge in "Fix exception on ^C" - innocuous enough

Denver Gingerich created

I don't normally kill sgx-catapult from the command-line so my tests
just cover use via Monit, but it worked fine in those tests so seems
good to merge.

See merge request !14 for the discussion and details behind the merge.

Change summary

sgx-catapult.rb | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

Detailed changes

sgx-catapult.rb 🔗

@@ -1032,11 +1032,13 @@ at_exit do
 		server.start do
 			["INT", "TERM"].each do |sig|
 				trap(sig) do
-					puts 'Shutting down gateway...'
-					SGXcatapult.shutdown
+					EM.defer do
+						puts 'Shutting down gateway...'
+						SGXcatapult.shutdown
 
-					puts 'Gateway has terminated.'
-					EM.stop
+						puts 'Gateway has terminated.'
+						EM.stop
+					end
 				end
 			end
 		end