Put the function in a separate thread. If the thread hasn't exited within the timeout, then detach it and let it run to finish in the background without getting any result from it.
Note that this won't work if the function has side-effects (like writing to a file).