It sounds like you're trying to track a change of state from "on" to "off", rather than just what state the switch is in. Presumably, there is some loop in your code that keeps running through all these things and checking the state of F_SW. What you need is to keep track of the current state and last state:
Code:
FLAG last_state, curr_state;
last_state = OFF // initialize to avoid hitting our condition on the first loop
loop
curr_state = read switch
if last_state == ON and curr_state == OFF // switch went from ON to OFF
do something