device: Add auto-cleanup function to unset the current action
This is useful in the functions where we have to unset the device's current action but we may use early-return to handle multiple conditions such as in open, close and delete functions. The latest also currently is a bit buggy as it won't reset the state on some failures.