# Handling surprise extraction

Surprise extraction occurs when the user opens the ejector handles and extracts a board before the Hot Swap LED is turned on. When this occurs, the event notifying closing the service (or context) may not be received.

Contexts that cannot be closed must be ignored. Attempts to use them or close them return CTAERR_INVALID_SEQUENCE.

The following scenario describes how surprise extraction can be detected by a Natural Access application:

1. The application receives HSWEVN_REMOVAL_REQUESTED and begins closing all context or services on the board that generated the event.

2. The application receives CTAEVN_DESTROY_CONTEXT_DONE or CTAEVN_CLOSE_SERVICES_DONE, depending on which function was used to close services on the board. The application saves information for each context if the close event or destroy event is received.

3. HSWEVN_BOARD_OFFLINE, HSWEVN_BOARD_REMOVED, or both occur. The application checks to see if all contexts have received the close or destroy event. If some contexts are in the pending state, the application must not try to use them again.