anchor.diff:      THandler = transactionlayer:get_handler_for_request(Request),
       LogTag = get_branchbase_from_handler(THandler),
   
  -    %% Check if request has To-tag, if so we reject it since we obviously lost the dialog state
  -    case sipheader:get_tag( keylist:fetch('to', Request#request.header) ) of
  -	none ->
  -	    request2(Request, Origin, LogStr, THandler, LogTag);
  -	_ ->
  -	    logger:log(normal, "~s: event server: Request has To-tag, answering '481 Call/Transaction Does Not Exist'",
  -		       [LogTag]),
  -	    ExtraHeaders = make_extraheaders(481, []),
  -	    transactionlayer:send_response_handler(THandler, 481, "Call/Transaction Does Not Exist", ExtraHeaders),
  -	    ok
  +    %% check if we are shutting down
  +    case is_shutting_down(THandler, LogTag) of
  +	true ->
  +	    ok;
  +	false ->
  +	    %% Check if request has To-tag, if so we reject it since we obviously lost the dialog state
  +	    case sipheader:get_tag( keylist:fetch('to', Request#request.header) ) of
  +		none ->
  +		    request2(Request, Origin, LogStr, THandler, LogTag);
  +		_ ->
  +		    logger:log(normal, "~s: event server: Request has To-tag, answering '481 Call/Transaction Does Not Exist'",
  +			       [LogTag]),
  +		    ExtraHeaders = make_extraheaders(481, []),
  +		    transactionlayer:send_response_handler(THandler, 481, "Call/Transaction Does Not Exist", ExtraHeaders),
  +		    ok
  +	    end
  +    end.
  +
  +is_shutting_down(THandler, LogTag) ->
  +    case ets:lookup(?EVENTSERVER_T, terminating) of
  +	[{terminating, Start}] when is_integer(Start) ->
  +	    logger:log(normal, "~s: event server: Performing shutdown, answering "
  +		       "'503 Service Unavailable (shutting down)'", [LogTag]),
  +	    Now = util:timestamp(),
  +	    RetryAfter = 1 + ?SHUTDOWN_TIMEOUT - (Now - Start),
  +	    transactionlayer:send_response_handler(THandler, 503, "Service Unavailable (shutting down)",
  +						   [{"Retry-After", [integer_to_list(RetryAfter)]}]),
  +	    true;
  +	[] ->
  +	    false
       end.
   
   %%
  
positive.code: %% Macros
  %%--------------------------------------------------------------------
  -define(ALLOW_METHODS, ["SUBSCRIBE", "PUBLISH", "OPTIONS"]).
  
  %%====================================================================
  %% Behaviour functions
  
negative.code: 			    end
  		    end, MySpecs, get_event_modules()),
  
      %% create ets table where we store application specific information
      ets:new(?EVENTSERVER_T, [public, set, named_table]),
  
      Tables = [user, numbers],
      [Tables, stateful, {append, Specs}].
  
  